TS Macro with INI
Posted: 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