Working on Tinkering Macro

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

AarynD
a lesser mummy
a lesser mummy
Posts: 45
Joined: Thu Jan 02, 2003 11:25 am

Working on Tinkering Macro

Post by AarynD » Fri Jan 03, 2003 12:37 pm

Working on modifying a tinkering macro found in the depot forum, mostly to learn the MQ macro language and how it's used... Here is the code I'm running right now:

Code: Select all

| - Tinker.mac - 
| 
#include routines.mac 

Sub Main
|  I prefer to use named vars, so will define those first.
	#define nToolbox v1
	#define nStartingPlat v2
	#define nAttempts v3
	#define nStartSkill v4
	#define nCurrSkill v5
	#define nSuccess
	#define nFail
	
|	Setting up my "events" to record successes and failures
	#event CombineFail "You lacked the skills to fashion the items together."
	#event CombineSuceed "You have fashioned the items together to create something new!"

	/varset nStartSkill $char(skill,"Tinkering")
	/varcalc nStartingPlat $char(plat)+$char(gold)/10
	/varset nCurrSkill $nStartSkill
	/varset nAttempts 0
	/varset nSuccess 0
	/varset nFail 0

	/mqlog Starting Macro with skill $nStartSkill and $nStartingPlat platinum.
	
   /call FindCombiner Tinkering 
   /if $return==99 /return 
   /varset nToolbox $return 

   :StartCombine
   /cleanup 
   /click right inv $nToolbox 

   /sendkey down ctrl 
   :MakeItem 

		/if $count("Gears")==0 {
			/echo Buy More Gears!
			/return }
	
		/if $count("Grease")==0 {
			/echo Buy More Grease!
			/return }
	
		/if $count("Gnomish Bolts")==0 {
			/echo Buy More Bolts!
			/return }

|      /if n $freeinv(space)<8 {
|			/echo No Free Space!
|			/return }
|	The above line was failing last night when attempted

      /if $pack($nToolbox,empty)!=FALSE {
			/echo Toolbox not empty!
			/return }

      /click left auto 
      /finditem "Gears" 
      /if $find()==FALSE /goto :Done 
      /click left pack $nToolbox 0 

      /finditem "Grease" 
      /if $find()==FALSE /goto :Done 
      /click left pack $nToolbox 1 

      /finditem "Gnomish Bolts" 
      /if $find()==FALSE /goto :Done 
      /click left pack $nToolbox 2 

      /click left pack $nToolbox combine 
      :WaitTillDone
         /delay 1 
      /if $pack($nToolbox,empty)==FALSE /goto :WaitTillDone
      /delay 1 
      /click left auto 
		/varadd nAttempts 1
		/doevents
		/echo $nAttempts attempts, $nSuccess successes, $nFail failures, current skill $char(skill,"Tinkering")
	
   /goto :MakeItem

  :Done 
  /sendkey up ctrl 
/return 

Sub Event_CombineFail
	/varadd nFail 1
/return

Sub Event_CombineSuccess
	/varadd nSuccess 1
/return


See any glaring problems in any of this? Also, while posting this, I noticed my tabs in the source code didn't translate correctly over to here. Does MQ allow for tabs in the source for easy reading, or do I need to convert tabs to normal spaces? Nothing about that in the readme file :/

Thanks for any help or pointers!

- Aaryn

AarynD
a lesser mummy
a lesser mummy
Posts: 45
Joined: Thu Jan 02, 2003 11:25 am

Errors...

Post by AarynD » Mon Jan 06, 2003 10:50 am

Code: Select all

|      /if n $freeinv(space)<8 { 
|         /echo No Free Space! 
|         /return } 
|   The above line was failing last night when attempted 

      /if $pack($nToolbox,empty)!=FALSE { 
         /echo Toolbox not empty! 
         /return } 
Both of these sections of the macro above are causing the script to fail... It's not actually bombing the script, it's just that the IF condition is evaluating to true, and the code is executed exiting the script... In both cases tho, it's wrong...

From the commandline, I can /echo $freeinv(space) and see that I have like 28 free inv slots. Yes this fails and returns from the macro. I can /echo $pack(7,empty) and get a TRUE returned, but the second piece of code still returns me out of the macro...

Any suggestions?

Aaryn

User avatar
Fippy
a snow griffon
a snow griffon
Posts: 499
Joined: Tue Jul 16, 2002 10:42 am

Post by Fippy » Mon Jan 06, 2003 11:26 am

Code: Select all

/if $pack($nToolbox,empty)!=FALSE { 
         /echo Toolbox not empty! 
         /return } 
this is wrong

if the toolbox is empty then $pack($nToolbox,empty) will be TRUE so your if will read

Code: Select all

/if TRUE!=FALSE { 
         /echo Toolbox not empty! 
         /return } 
which will be true since TRUE is not equal to FALSE. You need the to say

Code: Select all

/if $pack($nToolbox,empty)!=TRUE { 
         /echo Toolbox not empty! 
         /return 
} 
I am guessing that its a copy paste problem with the first one since /if n $freeinv(space)&8 is just nonsense and should be /if n $freeinv(space)<8
Fippy

This is my girl. But Rizwank had her first :-)
[img]http://www.btinternet.com/~artanor/images/fairy_bounce09.gif[/img]

AarynD
a lesser mummy
a lesser mummy
Posts: 45
Joined: Thu Jan 02, 2003 11:25 am

Thanks...

Post by AarynD » Mon Jan 06, 2003 1:11 pm

Yes, you're right, it was a copy/paste problem... The code reads as you stated, /if n $freeinv(space)<8. Like I said, I can go from the normal command line, and type in /echo $freeinv(space) and have it return the number of slots (roughly 24-28 slots), but the code here keeps running anyway, and dropping me out of the routine.

And thanks for the other one also, after looking at it a bit, I realized my logic was backwards... hehe, is what I get from cutting and pasting from someone else's code :p

- Aaryn