TS Macro with INI

Post your completed (working) macros here. Only for macros using MQ2Data syntax!

Moderator: MacroQuest Developers

Digitalxero
a ghoul
a ghoul
Posts: 129
Joined: Tue Sep 10, 2002 5:01 pm

TS Macro with INI

Post by Digitalxero » Tue May 04, 2004 12:56 am

Code: Select all

|New TradeSkill Macro
|ts.mac [tradeskill.mac]
|Author: Digitalxero
|Usage: /macro ts.mac <recipe> <options>
|Example: /macro ts.mac "Metal Bits" "Camp=1 EndOnTrivial=1 KeepItem=0 Spam=0 Delay=3"
|Setting Options: NumCombines EndOnTrivial, KeepItem, Report, PauseOnTell, Delay, Spam, Camp
|Defaults;
|NumCombines -1
|EndOnTrivial 0
|KeepItem 1
|Report 1
|PauseOnTell 1
|Delay 1
|Spam 1
|Camp 0

#define INIFile "recipes.ini"

#event SkillTrivial "You can no longer advance your skill from making this item"
#event SkillUp "You have become better at"
#event SkillFailure "You lacked the skills"
#event SkillSuccess "You have fashioned the items together to create something new"
#event FullInventory "There was no place to put that"
#event CombineError "You cannot combine these items in this container type!"
#chat tell

Sub Main
|Setting Variables
/declare NumCombines int outer -1
/declare EndOnTrivial int outer 0
/declare KeepItem int outer 1
/declare PauseOnTell int outer 1
/declare Spam int outer 1
/declare Report int outer 1
/declare Camp int outer 0
/declare Delay int outer 1
/if (${Bool[${Param1}]}) /declare Options string outer ${Param1}


|Other Variables
/declare TotalComponants int outer 0
/declare CompArray[10,2] string outer
/declare IniValue string outer
/declare Container[2] string outer
/declare ErrorText string outer

|Report Variables
/declare ReportText string outer
/declare RecipeName string outer ${Param0}
/declare Attempts int outer 0
/declare Success int outer 0
/declare Failure int outer 0
/declare SkillUps int outer 0

|Inventory Slot Variables
/declare InvNums[30] int outer
/declare PackName[30] string outer
/declare DropSlot int outer

|For loop Variable
/declare i int outer 0

|Temparary Variables
/declare TempString string outer
/declare TempInt int outer

/call SetPackList

/if (${Bool[${Options}]}) /call Get_Settings


/call Comp_List
:Start
/doevents
/call Have_Comps
/call Do_Combine
/if (${NumCombines}==0) {
    /varset ErrorText Compleated ${Attempts}
    /call End_Macro
}
/goto :Start
/return

Sub Get_Settings
    /declare NumArgs int local ${Math.Calc[${Options.Count[ ]}+1]}
    /for i 1 to ${NumAurgs}
        /varset ${Options.Arg[${i}].Left[${Math.Calc[${Options.Legnth}-2]}]} ${Options.Arg[${i}].Right[1]}
        /if (${Spam}==1) /echo Setting ${Options.Arg[${i}].Left[${Math.Calc[${Options.Legnth}-2]}]} to ${Options.Arg[${i}].Right[1]}
    /next i
/return

Sub Comp_List
    /varset IniValue ${Ini[INIFile, ${RecipeName}, Cont]}
    /if (${Bool[${IniValue.Equal[enviro]}]} || ${Bool[${IniValue.Equal[Enviro]}]}) {
        /varset Container[1] enviro
        /varset Container[2] enviro
        /if (${Spam}==1) /echo Setting Container to: Enviromental Container
    } else {
        /varset Container[1] ${FindItem[${IniValue}].Name}
        /varset Container[2] ${PackName[${FindItem[${Container[1]}].InvSlot}]}
        /if (${Spam}==1) /echo Setting Container to: ${Container[1]} in ${Container[2]}
    }
    /for i 0 to 9
        /varset IniValue ${Ini[INIFile, ${RecipeName}, Comp${i}]}
        /if (${Bool[${IniValue}]}) {
            /varset CompArray[${Math.Calc[${i}+1]},1] ${FindItem[${IniValue}].Name}
            /varset CompArray[${Math.Calc[${i}+1]},2] ${FindItem[${IniValue}].InvSlot}
            /varcalc TotalComponants ${TotalComponants}+1
            /if (${Spam}==1) /echo Component ${TotalComponants}: ${FindItem[${IniValue}].Name}
        }
    /next i
    /doevents
/return

Sub Have_Comps
    /for i 1 to ${TotalComponants}
        /if (!${Bool[${FindItem[=${CompArray[${i},1]}]}]}) {
            /varset ErrorText Missing ${CompArray[${i},1]}
            /call End_Macro
        }
    /next i
    /doevents
/return

Sub Do_Combine
    /varset DropSlot ${InvNums[${FindItem[=${Container[1]}].InvSlot}]}
    /for i 1 to ${TotalComponants}
        /if (${Spam}==1) /echo Picking up ${CompArray[${i},1]}
        /ctrl /itemnotify ${CompArray.Int[${i},2]} leftmouseup
        /call pickup
        /if (${Container[1].Equal[enviro]}) {
            /if (${Spam}==1) /echo Puting ${CompArray[${i},1]} into Slot: ${InvSlot[enviro${i}]}
            /itemnotify ${InvSlot[enviro${i}]} leftmouseup
            /call drop
        } else {
            /varcalc DropSlot ${DropSlot}+1
            /if (${Spam}==1) /echo Puting ${CompArray[${i},1]} into Slot: ${InvSlot[enviro${i}]}
            /itemnotify ${DropSlot} leftmouseup
            /call drop
        }
    /next i
    /combine ${Container[2]}
    /if (${Spam}==1) /echo Delaying ${Delay} seconds
    /delay ${Delay}s
    /call AutoInv
    /if (${NumCombines}>0) /varcalc NumCombines ${NumCombines}-1
    /varcalc Attempts ${Attempts}+1
    /doevents
/return

Sub AutoInv
    :AutoInv
    /if (${Cursor.ID}) {
        /if (${KeepItem}==0) {
            :Destroy
	    /for i 1 to ${TotalComponants}
		/if (!${Cursor.Name.Equal[${CompArray[${i},1]}]}) {
		    /if (${Spam}==1) /echo Destroying: ${Cursor.Name}
		    /destroy
		    /if (${Spam}==1) /echo Delaying ${Delay} seconds
		    /delay ${Delay}s
		}
	    /next i
	    /if (${Cursor.ID}) {
		/if (${Spam}==1) /echo Keeping: ${Cursor.Name}
		/autoinv
		/if (${Spam}==1) /echo Delaying ${Delay} seconds
	        /delay ${Delay}s
	    }
	} else {
	    /if (${Spam}==1) /echo Keeping: ${Cursor.Name}
	    /autoinv
	    /if (${Spam}==1) /echo Delaying ${Delay} seconds
	    /delay ${Delay}s
	}
	/goto :AutoInv
    }
    /doevents
/return

Sub pickup
    :Wait
    /if (!${Cursor.ID}) {
        /if (${Spam}==1) /echo Waiting for the Item to get the fuck on the cursor!
        /if (${Spam}==1) /echo Delaying ${Delay} seconds
        /delay ${Delay}s
        /goto :Wait
    }
    /doevents
/return

Sub drop
    :Wait
    /if (${Cursor.ID}) {
        /if (${Spam}==1) /echo Waiting for the Item to get the fuck off the cursor!
        /if (${Spam}==1) /echo Delaying ${Delay} seconds
        /delay ${Delay}s
        /goto :Wait
    }
    /doevents
/return

Sub Pause
    /if (${Spam}==1) /echo Macro Paused!
    :Pause
    /if (${Target.Name.Equal[${Me.Name}]}) /goto :Pause
    /if (${Spam}==1) /echo Macro Continuing!
/return

Sub SetPackList
    /varset InvNums[22] 250
    /varset InvNums[23] 260
    /varset InvNums[24] 270
    /varset InvNums[25] 280
    /varset InvNums[26] 290
    /varset InvNums[27] 300
    /varset InvNums[28] 310
    /varset InvNums[29] 320
    /varset PackName[22] pack1
    /varset PackName[23] pack2
    /varset PackName[24] pack3
    /varset PackName[25] pack4
    /varset PackName[26] pack5
    /varset PackName[27] pack6
    /varset PackName[28] pack7
    /varset PackName[29] pack8
    /doevents
/return

Sub GenReport
    /varset ReportText Finished makeing ${RecipeName} in ${Attempts} Attempts with ${Success} Successes and ${Failure} Failures for a ${Math.Calc[${Success}/${Attempts}*100]} percent Success
/return

Sub End_Macro
    /if (${ErrorText.Length}>0) /echo ${ErrorText}
    /if (${Report}==1) {
        /call GenReport
        /echo ${ReportText}
    }
    /if (${Camp}==1) {
        /sit
        /camp desktop
    }
    /endmacro
/return

Sub Event_Chat
     /if (${PauseOnTell}==1) {
         /target myself
         /call Pause
     }
/return

Sub Event_SkillTrivial
    /if (${EndOnTrivial}==1) {
        /varset ErrorText This Item is now Trivial so I am ending the macro now.
        /call End_Macro
    }
/return

Sub Event_SkillUp
    /varcals SkillUps ${SkillUps}+1
/return

Sub Event_SkillFailure
    /varcalc Failure ${Failure}+1
/return

Sub Event_SkillSuccess
    /varcalc Success ${Success}+1
/return

Sub Event_FullInventory
    /varset ErrorText Your Inventory is full.
    /call End_Macro
/return

Sub Event_CombineError
    /varset ErrorText You are using the wrong container dumb fuck!
    /call End_Macro
/return

DumbStruck
a ghoul
a ghoul
Posts: 125
Joined: Fri Apr 30, 2004 8:46 am

i Guess

Post by DumbStruck » Tue May 04, 2004 6:54 am

macro looks nice but what is the ini file supposed to look like ?

Digitalxero
a ghoul
a ghoul
Posts: 129
Joined: Tue Sep 10, 2002 5:01 pm

Post by Digitalxero » Tue May 04, 2004 12:06 pm

Here ya go

Code: Select all

[jumjum salad]
Cont=mixing
Comp0=Fennel
Comp1="jumjum stalk"
Comp2=Vegtables
Comp3=Lettuce

[jumjum beer]
Cont=enviro
Comp0=flask
Comp1=spices
Comp2=bottle
Comp3="jumjum stalk"
Comp4=barly
Comp5=hops

[woven mandrake]
Cont=sewing
Comp0="mandrake root"
Comp1="mandrake root"

[royal mints]
Cont=mixing
Comp0=frosting
Comp1="eucalyptus leaf"

[mature cheese]
Cont=mixing
Comp0=milk
Comp1=milk
Comp2="dairy spoon"
Comp3="rennet"

[dairy spoon]
Cont=enviro
Comp0="water flask"
Comp1="scaler mold"
Comp2="metal bits"
Comp3="metal bits"

[picnic basket]
Cont=sewing
Comp0="woven mandrake"
Comp1="steel boning"

[steel boning]
Cont=enviro
Comp0="small brick of ore"
Comp1="water flask"
Comp2=file

[file]
Cont=enviro
Comp0="water flask"
Comp1="metal bits"
Comp2="file mold"

[metal bits]
Cont=enviro
Comp0="small piece of ore"
Comp1="small piece of ore"
Comp2="water flask"

[marmalade sandwich]
Cont=mixing
Comp0="apricot marmalade"
Comp1="loaf of bread"

[apricot marmalade]
Cont=spit
Comp0=frosting
Comp1=frosting
Comp2=frosting
Comp3=fruit

[loaf of bread]
Cont=spit
Comp0="clump of dough"
Comp1="bread tin"

[clump of dough]
Cont=mixing
Comp0=#egg
Comp1="bottle of milk"
Comp2="cup of flour"

[bread tin]
Cont=enviro
Comp0="water flask"
Comp1="metal bits"
Comp2="bread tin mold"
Comp3="ceramic lining"

[ceramic lining]
Cont=enviro
Comp0="unfired ceramic lining"
Comp1="quality firing sheet"

[unfired ceramic lining]
Cont=enviro
Comp0="water flask"
Comp1="ceramic lining sketch"
Comp2="small block of clay"

[slice of jumjum cake]
Cont=spit
Comp0="jumjum cake"

[jumjum cake]
Cont=spit
Comp0="jumjum stalk"
Comp1=frosting
Comp2="clump of dough"
Comp3="winter chocolate"
Comp4="cake round"

[winter chocolate]
Cont=mixing
Comp0="brownie parts"
Comp1=frosting
Comp2=frosting

[cake round]
Cont=enviro
Comp0="water flask"
Comp1="metal bits"
Comp2="cake round mold"
Comp3="ceramic lining"

[slice of jumjum cake]
Cont=spit
Comp0="jumjum cake"

[misty thicket picnic]
Cont=enviro
Comp0="marmalade sandwich"
Comp1="jumjum salad"
Comp2="royal mints"
Comp3="slice of jumjum cake"
Comp4="slice of jumjum cake"
Comp5="mature cheese"
Comp6="picnic basket"
Comp7="jumjum spiced beer"

[Celestial Essence]
Cont=mixing
Comp0="celestial solvent"
Comp1="the scent of marr"

[Silk Swatch]
Cont="Coldain Tanner"
Comp0="spider silk"
Comp1="spider silk"

[Blessed Dust of Tunare]
Cont=enviro
Comp0="imbued emerald"
Comp1="jar of acid"
Comp2="celestial essence"

[Sacred Tunare Silk]
Cont="Coldain Tanner"
Comp0="spider silk"
Comp1="blessed dust of tunare"
Comp2="celestial essence"

[Dressing]
Cont=mixing
Comp0="vegetable oil"
Comp1="vinegar"

[Smoked Hero Parts]
Cont=enviro
Comp0="hero parts"
Comp1="smoker"
Comp2="spices"

[Spiced Hero Parts]
Cont=enviro
Comp0="hero parts"
Comp1="jug of sauces"
Comp2="spices"

DumbStruck
a ghoul
a ghoul
Posts: 125
Joined: Fri Apr 30, 2004 8:46 am

what can it be

Post by DumbStruck » Tue May 04, 2004 6:37 pm

Grrr these macros with ini files never work for me . i have ini file in macro dir and ini dir . am i doing something wrong ?

/macro ts Codoil

i get subroutine main wasnt found

Digitalxero
a ghoul
a ghoul
Posts: 129
Joined: Tue Sep 10, 2002 5:01 pm

Post by Digitalxero » Tue May 04, 2004 8:04 pm

try the following mac and if you get same error you have more issues then ini

Code: Select all

Sub Main
/echo Boo
/return

DumbStruck
a ghoul
a ghoul
Posts: 125
Joined: Fri Apr 30, 2004 8:46 am

hmm

Post by DumbStruck » Wed May 05, 2004 8:23 am

I use a fishing mac works all the time dont know why i cant get this one to work . A stupid question am i supposed to use quotes ? /macro ts codoil or should it be /macro ts "codOil"

IM totally DUMBSTRUCK.. Thanx for the help.

TheWarden
a hill giant
a hill giant
Posts: 253
Joined: Sat Dec 27, 2003 3:51 pm
Location: In your bushes...

Post by TheWarden » Wed May 05, 2004 11:15 am

He's go it right in there :P

Code: Select all

|Example: /macro ts.mac "Metal Bits"

s16z
a ghoul
a ghoul
Posts: 97
Joined: Thu Apr 01, 2004 12:03 pm

Post by s16z » Wed May 05, 2004 11:28 am

Code: Select all

|Example: /macro ts.mac "Metal Bits"
The quotes in this example allows the parser to recognize that "Metal Bits" is one item, not two. So you get Param0=Metal Bits, rather than Param0=Metal and Param1=Bits.

Digitalxero
a ghoul
a ghoul
Posts: 129
Joined: Tue Sep 10, 2002 5:01 pm

Post by Digitalxero » Wed May 05, 2004 2:45 pm

Post the ini section for codoil and I will tell you what you need to type with out that I would only be guessing since it is case sensitive and shit like that :P

Code: Select all

[Cod Oil]
Cont=enviro
Comp0="cobalt cod"
Comp1="water flask"

Code: Select all

/macro ts "Cod Oil"