Page 1 of 1

Simple, general purpose combine macro

Posted: Fri Apr 30, 2004 10:48 am
by Groo
Simple, general purpose combine macro

Code: Select all

| Combine.mac by Groo Apr 29, 2004

#event CombineError "There was no place to put that"
#event CombineError "You cannot combine these items in this container type!"
#event CombineError "did not accept these items"
#chat tell

Sub Main 
    /declare PackCode string outer
    /declare Component[10] string outer
    /declare i int outer

	/if (!${Defined[Param0]}) {
		/echo No recipe name given
		/endmacro
	}
    /call readIni "${Param0}"
    :Begin 
	    /call ClearCursor
	    /for i 1 to 10
	       	/call AddComp "${Component[${i}]}" ${i}
	    /next i
	    /call DoCombine 
	    /goto :Begin 
	/return 

Sub readIni(RecipeName) 
    /declare Container string

    /echo Running ${RecipeName} recipe

	/if (${Ini["recipes.ini","${RecipeName}",-1,"NOTFOUND"].Equal["NOTFOUND"]}) {
        /echo Recipe ${RecipeName} not found 
        /endmacro 
    } 

	/varset Container ${Ini[recipes.ini,${RecipeName},Cont,Enviro]}

	/if (${Container.Equal[Enviro]}) { 
        /varset PackCode Enviro
	} else {
        /varset PackCode ${FindItem[=${Container}].InvSlot}
		
		/if (${PackCode.Equal[NULL]}) { 
			/echo Could not find container ${Container}
		    /endmacro 
		}
		| pack1 = 22, ... , pack8 = 29
		/varset PackCode pack${Math.Calc[${PackCode}-21].Int}
	}  

    /for i 1 to 10
        /varset Component[${i}] ${Ini[recipes.ini,${RecipeName},Comp${Math.Calc[${i}-1].Int},NOTFOUND]}
    /next i 
    /return

sub ClearCursor 
    :Loop 
		/if (!${Cursor.ID}) /return
		/autoinv
		/delay 5
		/doevents 
		/goto :Loop 
    /return 

sub DoCombine 
    :Loop 
		/combine ${PackCode}
		/delay 1s
		/if (${PackCode.Equal[Enviro]}) /delay 1s
	    /doevents 
		/if (${InvSlot[${PackCode}].Item.Items}) /goto :Loop
	/delay 5
    /return 

sub AddComp(CompName, PackSlot)
	/if (${CompName.Equal[NOTFOUND]}) /return

	/if (!${FindItem[=${CompName}].ID}) {
        /echo Could not find ${CompName} in inventory
		/beep
	    /endmacro 
    }

	:Loop 
		/ctrl /itemnotify ${FindItem[=${CompName}].InvSlot} leftmouseup

		/if (!${Cursor.ID}) {
			/delay 1
			/goto :Loop
		}

	/if (${PackCode.Equal[Enviro]}) { 
		/itemnotify ${InvSlot[enviro${PackSlot}]} leftmouseup
	} else {
		/itemnotify in ${PackCode} ${PackSlot} leftmouseup
	}	
	/return 

Sub Event_CombineError 
    /endmacro 
    /return 
Uses the standard Recipe.ini file. Here is a small example.

Code: Select all

------------- Ethereal Sheet of Metal ------------

[EthSheet]
Cont=Enviro
Comp0=Brick of Ethereal Energy
Comp1=Brick of Ethereal Energy
Comp2=Ethereal Temper
Comp3=Tanaan Smithing Hammer

[EthTemper]
Cont=Enviro
Comp0=Celestial Essence
Comp1=Celestial Essence
Comp2=Emerald Tea Leaf
Comp3=Soda

[CE]
Cont=Mixing Bowl
Comp0=Celestial Solvent
Comp1=The Scent Of Marr


Posted: Fri Apr 30, 2004 1:58 pm
by JimJohnson
/macro combine CE gives

Code: Select all

[MQ2] Running CE recipe
[MQ2] Recipe CE not found

useing your example ini you posted

Latest MQ2

Posted: Fri Apr 30, 2004 4:31 pm
by ImaNoob
Dude I had the same problem, get the latest MQ2, this solves the problem.

Posted: Fri Apr 30, 2004 5:03 pm
by JimJohnson
have the latest zip and thats what i got

Posted: Fri Apr 30, 2004 5:22 pm
by Preocts
Just a few cleanups I'd like to suggest.

Code: Select all

   /if (!${Defined[Param0]}) { 
      /echo No recipe name given 
      /endmacro 
   } 
This will never happen with the new system Param0 is always defined.

Code: Select all

   /if (!${Param0.Length}) { 
      /echo No recipe name given 
      /endmacro 
   } 
A few quarks about the Ini returns to help with ini scanning need to be counted for.

Code: Select all

   /if (${Ini[recipes.ini,${RecipeName},-1,NOTFOUND].Find[NOTFOUND]}) { 
        /echo Recipe ${RecipeName} not found 
        /endmacro 
    } 
Notice lack of " marks, and we use Find not Equal because when the default value is returned MQ adds a || to it. Guess you could do ".Equal[NOTFOUND||]

Make a quick glance, this is what I saw. Nice use of an ini file.

Posted: Mon May 03, 2004 1:18 am
by JimJohnson
You need to edit your main post and put the right example ini file btw.


its Recipes.ini you have it singular

MAN

Posted: Tue May 04, 2004 10:49 am
by DumbStruck
I cant get this one to work for crap . what am i doing wrong . any one have a generic ts with out the ini . one where i can just highlight a saved recipe and it works ? im new at this and have minimal coding expertise