Calling of the macro is:
/macro halas <shortname> [<quant>]
where <shortname> is the name of the recipe you want made, <quant> is the quantity you want when done with combines. If you do not specify a quantity then it will make until it runs out of parts. This is great in some cases, bad in others because it does not make sure there is room in inventory for what you are making.
You must open all your packs to run this and you must have the enviro combiner already open if the recipe calls for enviro. The macro will verify that there is a combine button where the enviro container combine button should be. (This could be misleading if you position another combiner pack over the enviro such that the combine buttons just happen to be in the same place). If you insure they do not overlap then this will work fine.
The recipe's allow for 2 stage setup where first stage allows for calling multiple subrecipes, and the second stage is the actual subrecipe. Look over the macro for details.
Feel free to adapt to other recipes or comment. Maxed baking last week using this and variations for other recipes.
Code: Select all
|This macro has several features to aid in the construction of halas 10lb meat
|pies. It has commands to allow making parts and when they have all been made,
|for making the final combines.
|
|Calling of the macro is: /macro halas <shortname> [<quant>]
|
|where <shortname> is the name of the recipe you want made, <quant> is the
|quantity you want when done with combines. If you do not specify a quantity
|then it will make until it runs out of parts. This is great in some cases,
|bad in others because it does not make sure there is room in inventory for
|what you are making.
|
|You must open all your packs to run this and you must have the enviro combiner
|already open if the recipe calls for enviro. The macro will verify that there
|is a combine button where the enviro container combine button should be. (This
|could be misleading if you position another combiner pack over the enviro such
|that the combine buttons just happen to be in the same place). If you insure
|they do not overlap then this will work fine.
|
|The recipe's allow for 2 stage setup where first stage allows for calling
|multiple subrecipes, and the second stage is the actual subrecipe. Look over
|the macro for details.
|
|variable usage
| v61 Ingredients in Recipe
| v62 combiner name
| v63 slots needed for recipe
| v64 slots in combiner
| v65 combine status
| v66 trivial status
| v67 quantity made
| v68 item made name
| v69 quantity when done
| t8 timer for max delay to empty cursor
| t9 timer for max delay after hit combine
#event CombineFail "You lacked the skills to fashion the items together."
#event CombineTriv "You can no longer advance your skill from making this item."
#event CombineAlt "You have fashioned the items together to create an alternate product."
#event CombineWork "You have fashioned the items together to create something new!"
#event CombineEmpty "You must place items in this object in order to create something new."
#event CombineWrong "You cannot combine these items in this combiner type!"
#event MissingItem "Couldn't find a "
#event Skillup "You have become better at "
Sub Main
/if "$p0"=="" {
/echo you need to tell me what to find
/return
}
/varset l0 0
/if "$p1"!="" {
/varcalc l0 $p1
}
/if "$p0"=="fillet" {
/call Make "fbear" 0
/call Make "flion" 0
/call Make "fwolf" 30
/call Make "fmam" 30
/goto :MainDone
}
/if "$p0"=="cfillet" {
/call Make "cbear" 20
/call Make "clion" 20
/call Make "cwolf" 20
/call Make "cmam" 20
/goto :MainDone
}
/call Make $p0 $l0
:MainDone
/return
Sub Make
| $p0 Recipe to make
| $p1 quantity required
| number of combines attempted
/varset v71 0
| number of combines succeeded
/varset v72 0
| number of skillups
/varset v73 0
| reset trivial status
/varset v66 0
/varset v69 0
/if "$p1"!="" {
/varcalc v69 $p1
}
/if "$p0"=="dress" {
/varset a(1,1) "Vinegar"
/varset a(1,2) 1
/varset a(2,1) "Vegetable Oil"
/varset a(2,2) 1
/varset v61 2
/varset v62 "mixing bowl"
/varset v63 2
/varset v68 "Dressing"
/goto :RecipeFound
}
/if "$p0"=="vego" {
/varset a(1,1) "Vegetables"
/varset a(1,2) 1
/varset a(2,1) "Water Flask"
/varset a(2,2) 1
/varset v61 2
/varset v62 "enviro"
/varset v63 2
/varset v68 "Vegetable Oil"
/goto :RecipeFound
}
/if "$p0"=="meph" {
/varset a(1,1) "Mephit Meat"
/varset a(1,2) 1
/varset a(2,1) "Dressing"
/varset a(2,2) 1
/varset a(3,1) "Loaf of Bread"
/varset a(3,2) 1
/varset v61 3
/varset v62 "spit"
/varset v63 3
/varset v68 "Mephit Sandwich"
/goto :RecipeFound
}
/if "$p0"=="flion" {
/varset a(1,1) "Lion Meat"
/varset a(1,2) 1
/varset a(2,1) "Filleting Knife"
/varset a(2,2) 1
/varset v61 2
/varset v62 "spit"
/varset v63 2
/varset v68 "Filleted Lion"
/goto :RecipeFound
}
/if "$p0"=="fbear" {
/varset a(1,1) "Bear Meat"
/varset a(1,2) 1
/varset a(2,1) "Filleting Knife"
/varset a(2,2) 1
/varset v61 2
/varset v62 "spit"
/varset v68 "Filleted Bear"
/varset v63 2
/goto :RecipeFound
}
/if "$p0"=="fwolf" {
/varset a(1,1) "Wolf Meat"
/varset a(1,2) 1
/varset a(2,1) "Filleting Knife"
/varset a(2,2) 1
/varset v61 2
/varset v62 "spit"
/varset v63 2
/varset v68 "Filleted Wolf"
/goto :RecipeFound
}
/if "$p0"=="fmam" {
/varset a(1,1) "Mammoth Meat"
/varset a(1,2) 1
/varset a(2,1) "Filleting Knife"
/varset a(2,2) 1
/varset v61 2
/varset v62 "spit"
/varset v63 2
/varset v68 "Filleted Mammoth"
/goto :RecipeFound
}
/if "$p0"=="clion" {
/varset a(1,1) "Filleted Lion"
/varset a(1,2) 1
/varset a(2,1) "Creamy Fennel Sauce"
/varset a(2,2) 1
/varset v61 2
/varset v62 "spit"
/varset v63 2
/varset v68 "Lion Fillet in Cream"
/goto :RecipeFound
}
/if "$p0"=="cbear" {
/varset a(1,1) "Filleted Bear"
/varset a(1,2) 1
/varset a(2,1) "Creamy Fennel Sauce"
/varset a(2,2) 1
/varset v61 2
/varset v62 "spit"
/varset v63 2
/varset v68 "Bear Fillet in Cream"
/goto :RecipeFound
}
/if "$p0"=="cwolf" {
/varset a(1,1) "Filleted Wolf"
/varset a(1,2) 1
/varset a(2,1) "Creamy Fennel Sauce"
/varset a(2,2) 1
/varset v61 2
/varset v62 "spit"
/varset v63 2
/varset v68 "Wolf Fillet in Cream"
/goto :RecipeFound
}
/if "$p0"=="cmam" {
/varset a(1,1) "Filleted Mammoth"
/varset a(1,2) 1
/varset a(2,1) "Creamy Fennel Sauce"
/varset a(2,2) 1
/varset v61 2
/varset v62 "spit"
/varset v63 2
/varset v68 "Mammoth Fillet in Cream"
/goto :RecipeFound
}
/if "$p0"=="fcream" {
/echo Loading Recipe for "$p0"
/varset a(1,1) "Cream"
/varset a(1,2) 1
/varset a(2,1) "Fennel"
/varset a(2,2) 1
/varset a(3,1) "Cup of Flour"
/varset a(3,2) 1
/varset v61 3
/varset v62 "mixing bowl"
/varset v63 3
/varset v68 "Creamy Fennel Sauce"
/goto :RecipeFound
}
/if "$p0"=="dough" {
/echo Loading Recipe for "$p0"
/varset a(1,1) "Bottle of Milk"
/varset a(1,2) 1
/varset a(2,1) "Wurm Egg"
/varset a(2,2) 1
/varset a(3,1) "Cup of Flour"
/varset a(3,2) 1
/varset v61 3
/varset v62 "mixing bowl"
/varset v63 3
/varset v68 "Clump of Dough"
/goto :RecipeFound
}
/if "$p0"=="cream" {
/echo Loading Recipe for "$p0"
/varset a(1,1) "Bottle of Milk"
/varset a(1,2) 2
/varset a(2,1) "Benzoin"
/varset a(2,2) 1
/varset a(3,1) "Dairy Spoon"
/varset a(3,2) 1
/varset v61 3
/varset v62 "mixing bowl"
/varset v63 4
/varset v68 "Cream"
/goto :RecipeFound
}
/if "$p0"=="halas" {
/echo Loading Recipe for "$p0"
/varset a(1,1) "Clump of Dough"
/varset a(1,2) 2
/varset a(2,1) "Sage Leaf"
/varset a(2,2) 1
/varset a(3,1) "Bear Fillet in Cream"
/varset a(3,2) 1
/varset a(4,1) "Lion Fillet in Cream"
/varset a(4,2) 1
/varset a(5,1) "Wolf Fillet in Cream"
/varset a(5,2) 1
/varset a(6,1) "Mammoth Fillet in Cream"
/varset a(6,2) 1
/varset a(7,1) "Pie Tin"
/varset a(7,2) 1
/varset v61 7
/varset v62 "enviro"
/varset v63 8
/varset v68 "Halas 10lb Meat Pie"
/goto :RecipeFound
}
/echo No recipe found for "$p0"
/return
:RecipeFound
| assume environment already good to go except maybe key status
/press ctrl
/press alt
/press shift
|
| give routine 5 seconds to empty the cursor
/call CleanCursor 5s
| verify combiner and get location
/call FindCombiner "$v62"
/if n $v64<$v63 /goto :BadSlots
/call TestCombiner
:MakeItTest
/varset l0 0
/if n $v69==0 /goto :MakeItTestLoop
/if n $count("$v68")<$v69 /goto :MakeItTestLoop
| /echo You already have $count("$v68") "$v68"
/return
:MakeItTestLoop
/varadd l0 1
/if n $l0>$v61 /Goto :MakeItTestDone
/if n $count("$a($l0,1)")<$a($l0,2) /goto :OutOfParts
/goto :MakeItTestLoop
:MakeItTestDone
/varset l0 0
/varset l1 0
:MakeItLoop
/varadd l0 1
/if n $l0>$v61 /goto :MakeItAlready
/varset l2 0
:MakeItAdd
/call GetItem "$a($l0,1)"
/varcalc l9 $return
/if n $l9!=0 {
/echo oops item "$a($l0,1)" not found
/return
}
/click left $v62 $l1
:DropLoop
/doevents
/if $cursor()==TRUE /goto :DropLoop
/varadd l1 1
/varadd l2 1
/if n $l2<$a($l0,2) /goto :MakeItAdd
/goto :MakeItLoop
:MakeItAlready
/varset v65 0
/varadd v71 1
/click left $v62 combine
/varset t9 10s
:WaitLoop
/doevents
/if n $v65>0 /goto :WaitOver
/if n $t9>0 /goto :WaitLoop
/echo Too much time waiting for combine - quitting
/return
:WaitOver
/varset t9 0
/call CleanCursor 5s
/goto :MakeItTest
:OutOfParts
/if n $v66==0 {
/mqlog Making "$v68"
/mqlog Stats - $v71 Attempts - $v72 Successes - $v73 Skillups
}
/return
:BadSlots
/echo Container "$v62" does not have enough slots for recipe ($v63 - $v64)
/endmacro
Sub GetItem
| $p0 is item to get
/varset v65 0
/sendkey down ctrl
/finditem "$p0"
/doevents
/if $Find()==FALSE /goto :NotFound
:FindLoop
/if $cursor()==TRUE /goto :FoundIt
/doevents
/if n $v65==1 /goto :NotFound
/if n $t9>0 /goto :FindLoop
:NotFound
/varset v65 1
:FoundIt
/varset t9 0
/sendkey up ctrl
/return $v65
Sub TestCombiner
| setup looping to allow an attempt to empty the combiner
/varset l0 0
:TestCombinerLoop
| will use values in global variables for testing
| flush any current pending events
/doevents flush
| set current status to no response - allow 10s for response
/varset v65 0
/varset t9 10s
/click left $v62 combine
:TestCombinerWait
/delay 3
/doevents
/if n $v65>0 /goto :TestCombinerResult
/if n $t9>0 /goto :TestCombinerWait
:TestCombinerResult
/varset t9 0
/if n $v65==0 {
/echo Combiner ($v62) did not respond to click combine - exiting
/endmacro
}
/if n $v65!=2 /goto :TestCombinerGood
| make up to 3 attempts to empty the pack
/if n $l0<3 {
/call CleanPack
/varadd l0 1
/goto :TestCombinerLoop
}
/echo Combiner ($v62) could not be emptied - exiting
/endmacro
:TestCombinerGood
/return
Sub CleanPack
| This routine will attempt to remove all items from the specified pack
| if unsuccessful it will abort
| make sure we pick up whole stacks
/press shift
/sendkey down shift
| loop thru all slots in pack
/for l2 0 to $v64
/click left $v62 $l2
/delay 3
/doevents
/if $cursor()==TRUE /call CleanCursor 5s
/next v2
/sendkey up shift
/return
Sub CleanCursor
| $p0 time allowed to clear cursor
| this sub attempts to clear the cursor by /left click auto
| if it cannot clear the cursor within $p0 seconds it will end the macro
/doevents
/varset l0 0
/varset t8 $p0
:cleanloop
/click left auto
/delay 3
/doevents
/if $cursor()==NULL /goto :CleanCursorDone
/if n $t8>0 /goto :cleanloop
:CleanCursorDone
/varset t8 0
/if $cursor()==NULL /return
| allow for multiple items on cursor
/varadd l0 1
/if n $l0<11 /goto :cleanloop
/echo Unable to clear cursor - $cursor(name)
/endmacro
Sub FindCombiner
| $p0 combiner name
| if found returns combiner name in v62
| otherwise exits macro
/if "$p0"=="" {
/echo No combiner specified - exiting
/endmacro
}
/if "$p0"=="enviro" {
/varset v62 "enviro"
/varset v64 10
/return
}
/varset l0 0
:FindCombinerLoop
/if n $l0>7 /goto :FindCombinerBad
/if "$pack($left(1,$l0),name)"~~"$p0" /goto :FindCombinerDone
/varadd l0 1
/goto :FindCombinerLoop
:FindCombinerBad
/echo Combiner "$p0" not in inventory - exiting
/endmacro
:FindCombinerDone
/varset v62 "pack $left(1,$l0)"
/varset v64 $pack($left(1,$l0),slots)
/return
Sub Event_CombineFail
/varset v65 3
/return
Sub Event_CombineTriv
/varset v66 1
/return
Sub Event_CombineAlt
/varset v65 4
/return
Sub Event_CombineWork
/varset v65 5
/varadd v72 1
/return
Sub Event_CombineEmpty
/varset v65 1
/return
Sub Event_CombineWrong
/varset v65 2
/return
Sub Event_MissingItem
/varset v65 1
/return
Sub Event_Skillup
/varadd v73 1
/return
Sub Event_Timer
/echo timer $p0 went off
/return

