ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Guadah on July 08, 2008, 04:10:29 AM
-
Aloha!
Last night I woke up, and believe it or not, I was actually dreaming about scripting. So as I attempted to go back to sleep, I had this code running through my head, and really wanted to get it down. So I came downstairs at 3:45 am, and wrote out an Alchemy Assistant. A Potion Crafter I suppose you can call it.
The menu I am quite proud of, its better then any I've done in the past, and am using your (TM) Persistant Variable Subs in it as well. I attempted to test this out this morning (4 hours of writing), but it does not pull any reagents out of the resource chest.
I went over it a few times, but do not see the error, and I was wondering if you, or anybody could give it a eye-over, and if you could run that nice little Syntax Error finder thing, to bring up the error's in code that I tend to have.
I must say, this is the best script I've written to date, and I'm pretty happy with how the flow works. Give me some harsh feedback please, its the way I learn best.
set %alch_tool RQF
set %alch_tools_needed 5
set %tink_tool GTL_KTL_JTL
set %tink_tools_needed 2
set %bottle WUF
set %ingot_type ENK
set %board TLK
set %size1 130
set %size2 100
set %pot_to_make 100
set %amount_to_make 200
set %resources AVF_WUF_UUF_ZUF_XWS_YWS_YUF_OUF_XUF_TUF_YZF_NUF_KZF_KUF_RZF_MZF_JUF_WZF_SZF_JZF_ENK_TZF_YZF
set %catposx 30
set %selposx 230
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXXXXXXXXX MENU DESIGN XXXXXXXXXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
menu window title menu test
menu window color silver
menu window size 290 %size1
menu font bgcolor gray
menu shape potionbg 5 5 280 65 3 7 1 Black 7 Gray
menu font align right
menu text title 130 12 Resource Container:
menu text title 130 42 Potion Container:
menu font bgcolor silver
menu font align left
menu button target_resource_bag 230 10 30 24 Set
menu button target_dump_bag 230 40 30 24 Set
menu edit resource_bag 135 10 85 %resource_bag
menu edit dump_bag 135 40 85 %dump_bag
menu button start 170 75 55 25 Start
menu button quit 230 75 55 25 Quit
menu font size 9
menu font color marron
menu text titles 20 80 Select Type
menu text titles 115 80 Amount
menu button add_more 175 105 20 20 +
menu button remove 200 105 20 20 -
menu font size 8
menu font color black
menu combo create %pot_to_make 5 %size2 100
menu combo add %pot_to_make Total Refreshment
menu combo add %pot_to_make Greater Agility
menu combo add %pot_to_make Night Sight
menu combo add %pot_to_make Greater Heal
menu combo add %pot_to_make Greater Strength
menu combo add %pot_to_make Poison
menu combo add %pot_to_make Greater Poison
menu combo add %pot_to_make Deadly Poison
menu combo add %pot_to_make Greater Cure
menu combo add %pot_to_make Greater Explosion
menu combo add %pot_to_make Greater Conflagration
menu combo add %pot_to_make Greater Confusion Blast
menu combo add %pot_to_make Invisibility
menu combo add %pot_to_make Parasitic
menu combo add %pot_to_make Darkglow
menu edit %amount_to_make 110 %size2 50 0
menu show
gosub TM_GetPersistantVariable resource_bag
menu set resource_bag #result
menu get resource_bag
set %ResourceChest #menures
set #lobjectid %ResourceChest
event macro 17 0
wait 10
contpos 610 440
wait 10
gosub TM_GetPersistantVariable dump_bag
menu set dump_bag #result
menu get dump_bag
menuloop:
if #menuButton = target_resource_bag
{
set #targCurs 1
set_resource_bag:
if #targCurs = 1
goto set_resource_bag
Set %resource_bag #ltargetid
Set #lobjectid %resource_bag
Event Macro 17 0
wait 10
contpos 610 440
wait 10
menu font size 10
menu set resource_bag %resource_bag
gosub TM_SetPersistantVariable resource_bag %resource_bag
set #menubutton N/A
}
if #menuButton = target_dump_bag
{
set #targCurs 1
set_dump_bag:
if #targCurs = 1
goto set_dump_bag
Set %dump_bag #ltargetid
menu font size 10
menu set dump_bag %dump_bag
gosub TM_SetPersistantVariable dump_bag %dump_bag
set #menubutton N/A
}
if #menubutton = add_more
{
gosub add_more
set #menubutton N/A
}
if #menubutton = remove
{
gosub remove
set #menubutton N/A
}
if #menubutton = Start
{
set #menubutton N/A
set %size2 30
set %pot_to_make 100
set %amount_to_make 200
gosub loop
}
if #menubutton = Quit
{
set #menubutton N/A
display ok Thank you for using my script.$
+$
+Script is Halting$
menu hide
halt
}
goto menuloop
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXX SUB TO ADD ANOTHER OPTION XXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub add_more
set %size1 ( %size1 + 25 )
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
menu window size 290 %size1
menu font size 8
menu font color black
menu combo create %pot_to_make 5 %size2 100
menu combo add %pot_to_make Total Refreshment
menu combo add %pot_to_make Greater Agility
menu combo add %pot_to_make Night Sight
menu combo add %pot_to_make Greater Heal
menu combo add %pot_to_make Greater Strength
menu combo add %pot_to_make Poison
menu combo add %pot_to_make Greater Poison
menu combo add %pot_to_make Deadly Poison
menu combo add %pot_to_make Greater Cure
menu combo add %pot_to_make Greater Explosion
menu combo add %pot_to_make Greater Conflagration
menu combo add %pot_to_make Greater Confusion Blast
menu combo add %pot_to_make Invisibility
menu combo add %pot_to_make Parasitic
menu combo add %pot_to_make Darkglow
menu edit %amount_to_make 110 %size2 50 0
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXXX SUB TO REMOVE AN OPTION XXXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub remove
if %pot_to_make = 100
return
set %size1 ( %size1 - 25 )
set %size2 ( %size2 - 25 )
menu window size 290 %size1
menu delete %pot_to_make
menu delete %amount_to_make
set %pot_to_make ( %pot_to_make - 1 )
set %amount_to_make ( %amount_to_make - 1 )
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXXXXX MAIN LOOP FOR SCRIPT XXXXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub loop
crafting_loop:
gosub clear_pack
gosub check_tool %alch_tool %alch_tools_needed %catposx 110 %selposx 90
gosub check_tool %tink_tool %tink_tools_needed %catposx 110 %selposx 130
gosub potion_init
gosub grab_resources %bottle %reagent1 %reagent2
gosub craft_potion %alch_tool %alch_tools_needed %catposx %catposy %selposx %selposy
goto crafting_loop
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXX SUB TO FIND AND RETURN RESOURCES XXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub clear_pack
finditem %resources C_ , #backpackid
for %i 1 #findcnt
{
finditem %resources C_ , #backpackid
exevent drag #findid #findstack
wait 10
exevent dropc %resource_bag
wait 15
}
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXX SUB TO CHECK AND CRAFT TOOLS XXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub check_tool
finditem %1 C_ , #backpackid
if #findcnt >= %2
return
set %to_make ( %2 - #findcnt ) ; Sets a number of tools to make
set #lobjectid #findid
; --------------------------------
; This section looks for ingots, then pulls 100
finditem %ingot_type C_ , %resource_bag
for #findindex 1 #findcnt
{
event property #findid
if copper || shadow || bronze || agapite || gold || verite || valorite in #property
ignoreitem #findid
if ingots in #property && shadow notin #property
set %ingots #findid ; Finds only Iron Ingots
}
finditem %ingots C_ , %resource_bag
if #findcnt < 20
{
display ok You are out of ingots.$
+Please get more and resetart script.
gosub return_resources
halt
}
finditem %ingots C_ , %resource_bag
exevent drag #findid 100
wait 10
exevent dropc #backpackid
wait 15
; --------------------------------
; Makes tool required, and loops %to_make (number of tools needed) times
event macro 22 0
gosub gumpwait
set %x #contposx + %3
set %y #contposy + %4
click %x %y ; Selects Category
gosub gumpwait
for %i 1 %to_make
{
set %x #contposx + %5
set %y #contposy + %6
click %x %y ; Selects Tool
gosub gumpwait
}
gosub clear_pack
finditem %1 C_ , #backpackid
if #findcnt < %2
gosub check_tool
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXX SETS ITEMS NEEDED FOR EACH POTION XXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub potion_init
menu get %pot_to_make
if #menuRes = 1 ; Total Refreshment
{
set %reagent1 KUF ; Black Pearl
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 90
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 2 ; Greater Agility
{
set %reagent1 JUF ; Bloodmoss
set %reagent2 N/A ; N/A
set %required_reagent1 3
set %required_reagent2 N/A
set %catposy 110
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 3 ; Night Sight
{
set %reagent1 RZF ; Spider's Silk
set %reagent2 N/A ; N/A
set %required_reagent1 1
set %required_reagent2 N/A
set %catposy 130
set %selposy 70
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 4 ; Greater Heal
{
set %reagent1 JZF ; Ginseng
set %reagent2 N/A ; N/A
set %required_reagent1 7
set %required_reagent2 N/A
set %catposy 150
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 5 ; Greater Strength
{
set %reagent1 MZF ; Mandrake Root
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 170
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 6 ; Poison
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 2
set %required_reagent2 N/A
set %catposy 190
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 7 ; Greater Poison
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 4
set %required_reagent2 N/A
set %catposy 190
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 8 ; Deadly Poison
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 8
set %required_reagent2 N/A
set %catposy 190
set %selposy 130
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 9 ; Greater Cure
{
set %reagent1 KZF ; Garlic
set %reagent2 N/A ; N/A
set %required_reagent1 6
set %required_reagent2 N/A
set %catposy 210
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 10 ; Greater Explosion
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 10
set %required_reagent2 N/A
set %catposy 230
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 11 ; Greater Conflagration
{
set %reagent1 TZF ; Grave Dust
set %reagent2 N/A ; N/A
set %required_reagent1 10
set %required_reagent2 N/A
set %catposy 250
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 12 ; Greater Confusion Blast
{
set %reagent1 YZF ; Pig Iron
set %reagent2 N/A ; N/A
set %required_reagent1 10
set %required_reagent2 N/A
set %catposy 250
set %selposy 130
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 13 ; Invisibility
{
set %reagent1 JUF ; Bloodmoss
set %reagent2 WZF ; Nightshade
set %required_reagent1 4
set %required_reagent2 3
set %catposy 270
set %selposy 70
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 14 ; Parasitic
{
set %reagent1 YWS ; Parasitic Plant
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 270
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 15 ; Darkglow
{
set %reagent1 XWS ; Luminescent Fungi
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 270
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXX SUB TO FIND AND GRAB RESOURCES XXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub grab_resources
if %amount >= 100
set %grab 100
if %amount < 100
set %grab %amount
; Finds and grabs Bottles
finditem %bottle C_ , %resource_bag
exevent drag #findid %grab
wait 10
exevent dropc #backpackid
wait 15
; Finds and grabs Reagent #1
finditem %1 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
; Finds and grabs Reagent #2
finditem %2 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXX SUB FOR MAKING THE POTIONS XXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub craft_potion
repeat
finditem %reagent1 C_ , #backpackid
if #findcnt < %required_reagent
gosub grab_more_resources %reagent1
finditem %1 C_ , #backpackid
if #findcnt < %2
gosub check_tool %alch_tool %alch_tools_needed %catposx 110 %selposx 90
event macro 22 0
gosub gumpwait
set %x #contposx + %3
set %y #contposy + %4
click %x %y ; Category
gosub gumpwait
set %x #contposx + %5
set %y #contposy + %6
click %x %y ; Selection (Potion)
gosub gumpwait
finditem %bottle C_ , #backpackid
until #findcnt = 0
gosub clear_pack
set %amount ( %amount - %grab )
if %amount = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXX GUMP WAIT SUB, ENSURES GUMP IS UP XXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub gumpwait
set %timer #SCNT + 5
repeat
until #CONTNAME = generic_gump || #SCNT > %timer
if #contname <> generic_gump
{
event macro 17 0
}
Return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXX TRAILMYX'S PERSISTANT VARIABLE SUBS XXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub TM_GetPersistantVariable
set #RESULT %1 , _ , #CHARID
set #RESULT * . #RESULT
return #RESULT
sub TM_SetPersistantVariable
set #RESULT %1 , _ , #CHARID
set * . #RESULT %2
return
-
Here's the output from the syntax checker:
Method count: 55
Command count: 55
*** Pass 1 - Label accounting:
*** Warning - GOSUB return_resources - Line 225 has no matching SUBroutine
*** Warning - GOSUB grab_more_resources - Line 608 has no matching SUBroutine
Subroutine labels = 11
Tag labels = 4
44 Code block(s).
2 Warnings(s) encountered.
*** Pass 2 - Execution [SYNTAXCHECK]
0 Error(s) encountered.
-
Not bad for writing it off the top of my head in the wee hours of the morning. I corrected those two warnings, here it is again.
I'd love it if anybody could take a gander at it, to see if its written correctly.
set %alch_tool RQF
set %alch_tools_needed 5
set %tink_tool GTL_KTL_JTL
set %tink_tools_needed 2
set %bottle WUF
set %ingot_type ENK
set %board TLK
set %size1 130
set %size2 100
set %pot_to_make 100
set %amount_to_make 200
set %resources AVF_WUF_UUF_ZUF_XWS_YWS_YUF_OUF_XUF_TUF_YZF_NUF_KZF_KUF_RZF_MZF_JUF_WZF_SZF_JZF_ENK_TZF_YZF
set %catposx 30
set %selposx 230
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXXXXXXXXX MENU DESIGN XXXXXXXXXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
menu window title menu test
menu window color silver
menu window size 290 %size1
menu font bgcolor gray
menu shape potionbg 5 5 280 65 3 7 1 Black 7 Gray
menu font align right
menu text title 130 12 Resource Container:
menu text title 130 42 Potion Container:
menu font bgcolor silver
menu font align left
menu button target_resource_bag 230 10 30 24 Set
menu button target_dump_bag 230 40 30 24 Set
menu edit resource_bag 135 10 85 %resource_bag
menu edit dump_bag 135 40 85 %dump_bag
menu button start 170 75 55 25 Start
menu button quit 230 75 55 25 Quit
menu font size 9
menu font color marron
menu text titles 20 80 Select Type
menu text titles 115 80 Amount
menu button add_more 175 105 20 20 +
menu button remove 200 105 20 20 -
menu font size 8
menu font color black
menu combo create %pot_to_make 5 %size2 100
menu combo add %pot_to_make Total Refreshment
menu combo add %pot_to_make Greater Agility
menu combo add %pot_to_make Night Sight
menu combo add %pot_to_make Greater Heal
menu combo add %pot_to_make Greater Strength
menu combo add %pot_to_make Poison
menu combo add %pot_to_make Greater Poison
menu combo add %pot_to_make Deadly Poison
menu combo add %pot_to_make Greater Cure
menu combo add %pot_to_make Greater Explosion
menu combo add %pot_to_make Greater Conflagration
menu combo add %pot_to_make Greater Confusion Blast
menu combo add %pot_to_make Invisibility
menu combo add %pot_to_make Parasitic
menu combo add %pot_to_make Darkglow
menu edit %amount_to_make 110 %size2 50 0
menu show
gosub TM_GetPersistantVariable resource_bag
menu set resource_bag #result
menu get resource_bag
set %ResourceChest #menures
set #lobjectid %ResourceChest
event macro 17 0
wait 10
contpos 610 440
wait 10
gosub TM_GetPersistantVariable dump_bag
menu set dump_bag #result
menu get dump_bag
menuloop:
if #menuButton = target_resource_bag
{
set #targCurs 1
set_resource_bag:
if #targCurs = 1
goto set_resource_bag
Set %resource_bag #ltargetid
Set #lobjectid %resource_bag
Event Macro 17 0
wait 10
contpos 610 440
wait 10
menu font size 10
menu set resource_bag %resource_bag
gosub TM_SetPersistantVariable resource_bag %resource_bag
set #menubutton N/A
}
if #menuButton = target_dump_bag
{
set #targCurs 1
set_dump_bag:
if #targCurs = 1
goto set_dump_bag
Set %dump_bag #ltargetid
menu font size 10
menu set dump_bag %dump_bag
gosub TM_SetPersistantVariable dump_bag %dump_bag
set #menubutton N/A
}
if #menubutton = add_more
{
gosub add_more
set #menubutton N/A
}
if #menubutton = remove
{
gosub remove
set #menubutton N/A
}
if #menubutton = Start
{
set #menubutton N/A
set %size2 100
set %pot_to_make 100
set %amount_to_make 200
gosub loop
}
if #menubutton = Quit
{
set #menubutton N/A
display ok Thank you for using my script.$
+$
+Script is Halting$
menu hide
halt
}
goto menuloop
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXX SUB TO ADD ANOTHER OPTION XXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub add_more
set %size1 ( %size1 + 25 )
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
menu window size 290 %size1
menu font size 8
menu font color black
menu combo create %pot_to_make 5 %size2 100
menu combo add %pot_to_make Total Refreshment
menu combo add %pot_to_make Greater Agility
menu combo add %pot_to_make Night Sight
menu combo add %pot_to_make Greater Heal
menu combo add %pot_to_make Greater Strength
menu combo add %pot_to_make Poison
menu combo add %pot_to_make Greater Poison
menu combo add %pot_to_make Deadly Poison
menu combo add %pot_to_make Greater Cure
menu combo add %pot_to_make Greater Explosion
menu combo add %pot_to_make Greater Conflagration
menu combo add %pot_to_make Greater Confusion Blast
menu combo add %pot_to_make Invisibility
menu combo add %pot_to_make Parasitic
menu combo add %pot_to_make Darkglow
menu edit %amount_to_make 110 %size2 50 0
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXXX SUB TO REMOVE AN OPTION XXXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub remove
if %pot_to_make = 100
return
set %size1 ( %size1 - 25 )
set %size2 ( %size2 - 25 )
menu window size 290 %size1
menu delete %pot_to_make
menu delete %amount_to_make
set %pot_to_make ( %pot_to_make - 1 )
set %amount_to_make ( %amount_to_make - 1 )
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXXXXX MAIN LOOP FOR SCRIPT XXXXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub loop
crafting_loop:
gosub clear_pack
gosub check_tool %alch_tool %alch_tools_needed %catposx 110 %selposx 90
gosub check_tool %tink_tool %tink_tools_needed %catposx 110 %selposx 130
gosub potion_init
gosub grab_resources %bottle %reagent1 %reagent2
gosub craft_potion %alch_tool %alch_tools_needed %catposx %catposy %selposx %selposy
goto crafting_loop
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXX SUB TO FIND AND RETURN RESOURCES XXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub clear_pack
finditem %resources C_ , #backpackid
for %i 1 #findcnt
{
finditem %resources C_ , #backpackid
exevent drag #findid #findstack
wait 10
exevent dropc %resource_bag
wait 15
}
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXX SUB TO CHECK AND CRAFT TOOLS XXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub check_tool
finditem %1 C_ , #backpackid
if #findcnt >= %2
return
set %to_make ( %2 - #findcnt ) ; Sets a number of tools to make
set #lobjectid #findid
; --------------------------------
; This section looks for ingots, then pulls 100
finditem %ingot_type C_ , %resource_bag
for #findindex 1 #findcnt
{
event property #findid
if copper || shadow || bronze || agapite || gold || verite || valorite in #property
ignoreitem #findid
if ingots in #property && shadow notin #property
set %ingots #findid ; Finds only Iron Ingots
}
finditem %ingots C_ , %resource_bag
if #findcnt < 20
{
display ok You are out of ingots.$
+Please get more and resetart script.
gosub clear_pack
halt
}
finditem %ingots C_ , %resource_bag
exevent drag #findid 100
wait 10
exevent dropc #backpackid
wait 15
; --------------------------------
; Makes tool required, and loops %to_make (number of tools needed) times
event macro 22 0
gosub gumpwait
set %x #contposx + %3
set %y #contposy + %4
click %x %y ; Selects Category
gosub gumpwait
for %i 1 %to_make
{
set %x #contposx + %5
set %y #contposy + %6
click %x %y ; Selects Tool
gosub gumpwait
}
gosub clear_pack
finditem %1 C_ , #backpackid
if #findcnt < %2
gosub check_tool
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXX SETS ITEMS NEEDED FOR EACH POTION XXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub potion_init
menu get %pot_to_make
if #menuRes = 1 ; Total Refreshment
{
set %reagent1 KUF ; Black Pearl
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 90
set %selposy 90
menu getnum %amount_to_make
set %amount #menures
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
}
if #menuRes = 2 ; Greater Agility
{
set %reagent1 JUF ; Bloodmoss
set %reagent2 N/A ; N/A
set %required_reagent1 3
set %required_reagent2 N/A
set %catposy 110
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 3 ; Night Sight
{
set %reagent1 RZF ; Spider's Silk
set %reagent2 N/A ; N/A
set %required_reagent1 1
set %required_reagent2 N/A
set %catposy 130
set %selposy 70
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 4 ; Greater Heal
{
set %reagent1 JZF ; Ginseng
set %reagent2 N/A ; N/A
set %required_reagent1 7
set %required_reagent2 N/A
set %catposy 150
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 5 ; Greater Strength
{
set %reagent1 MZF ; Mandrake Root
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 170
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 6 ; Poison
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 2
set %required_reagent2 N/A
set %catposy 190
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 7 ; Greater Poison
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 4
set %required_reagent2 N/A
set %catposy 190
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 8 ; Deadly Poison
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 8
set %required_reagent2 N/A
set %catposy 190
set %selposy 130
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 9 ; Greater Cure
{
set %reagent1 KZF ; Garlic
set %reagent2 N/A ; N/A
set %required_reagent1 6
set %required_reagent2 N/A
set %catposy 210
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 10 ; Greater Explosion
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 10
set %required_reagent2 N/A
set %catposy 230
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 11 ; Greater Conflagration
{
set %reagent1 TZF ; Grave Dust
set %reagent2 N/A ; N/A
set %required_reagent1 10
set %required_reagent2 N/A
set %catposy 250
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 12 ; Greater Confusion Blast
{
set %reagent1 YZF ; Pig Iron
set %reagent2 N/A ; N/A
set %required_reagent1 10
set %required_reagent2 N/A
set %catposy 250
set %selposy 130
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 13 ; Invisibility
{
set %reagent1 JUF ; Bloodmoss
set %reagent2 WZF ; Nightshade
set %required_reagent1 4
set %required_reagent2 3
set %catposy 270
set %selposy 70
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 14 ; Parasitic
{
set %reagent1 YWS ; Parasitic Plant
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 270
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 15 ; Darkglow
{
set %reagent1 XWS ; Luminescent Fungi
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 270
set %selposy 110
menu getnum %amount_to_make
set %amount #menures
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
}
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXX SUB TO FIND AND GRAB RESOURCES XXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub grab_resources
if %amount >= 100
set %grab 100
if %amount < 100
set %grab %amount
; Finds and grabs Bottles
finditem %bottle C_ , %resource_bag
exevent drag #findid %grab
wait 10
exevent dropc #backpackid
wait 15
; Finds and grabs Reagent #1
finditem %1 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
; Finds and grabs Reagent #2
finditem %2 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
return
sub grab_more_resources
; Finds and grabs Reagent #1
finditem %1 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
; Finds and grabs Reagent #2
finditem %2 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXX SUB FOR MAKING THE POTIONS XXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub craft_potion
repeat
finditem %reagent1 C_ , #backpackid
if #findcnt < %required_reagent
gosub grab_more_resources %reagent1
finditem %1 C_ , #backpackid
if #findcnt < %2
gosub check_tool %alch_tool %alch_tools_needed %catposx 110 %selposx 90
event macro 22 0
gosub gumpwait
set %x #contposx + %3
set %y #contposy + %4
click %x %y ; Category
gosub gumpwait
set %x #contposx + %5
set %y #contposy + %6
click %x %y ; Selection (Potion)
gosub gumpwait
finditem %bottle C_ , #backpackid
until #findcnt = 0
gosub clear_pack
set %amount ( %amount - %grab )
if %amount = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXX GUMP WAIT SUB, ENSURES GUMP IS UP XXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub gumpwait
set %timer #SCNT + 5
repeat
until #CONTNAME = generic_gump || #SCNT > %timer
if #contname <> generic_gump
{
event macro 17 0
}
Return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXX TRAILMYX'S PERSISTANT VARIABLE SUBS XXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub TM_GetPersistantVariable
set #RESULT %1 , _ , #CHARID
set #RESULT * . #RESULT
return #RESULT
sub TM_SetPersistantVariable
set #RESULT %1 , _ , #CHARID
set * . #RESULT %2
return
-
Ran it through the syntax checker again for ya.
Method count: 55
Command count: 55
*** Pass 1 - Label accounting:
Subroutine labels = 12
Tag labels = 4
44 Code block(s).
0 Warnings(s) encountered.
*** Pass 2 - Execution [SYNTAXCHECK]
0 Error(s) encountered.
-
Does this still misbehave?
-
Yes, I think it must be an error in how I coded the variables. When it goes from start, and cycles through the loop, everything looks fine when I line through it (F7).
However when it gets to the pull resources loop, it goes through each line, but does not 'pull' the resources out. Only thing I can think of is that it does not set the items to pull correctly.
-
Your grab resources sub is a little light on the error checking. You might want to address what happens if you have the same resource in two or more stacks. You should probably look into a subroutine that does this with some checking to be sure you actually found an item before you start dragging it. I would make a universal subroutine that grabs 1 item at a time also. Here's an UNTESTED sub that I whipped up:
Deleted by TM
It's syntax is:
gosub grab_resource %resource_bag #BACKPACKID %bottle 100
The total amount grabbed is returned.
Again, this is untested and I did it in a hurry.... And I also refrained from using namespaces.
-
I've been doing some trouble shooting in this script.
Here again is the entire script:
set %alch_tool RQF
set %alch_tools_needed 5
set %tink_tool GTL_KTL_JTL
set %tink_tools_needed 2
set %bottle WUF
set %ingot_type ENK
set %board TLKset %size1 130
set %size2 100
set %pot_to_make 100
set %amount_to_make 200
set %resources AVF_WUF_UUF_ZUF_XWS_YWS_YUF_OUF_XUF_TUF_YZF_NUF_KZF_KUF_RZF_MZF_JUF_WZF_SZF_JZF_ENK_TZF_YZF
set %catposx 30
set %selposx 230
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXXXXXXXXX MENU DESIGN XXXXXXXXXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
menu window title Guadah's Alchemist Assistant
menu window color silver
menu window size 290 %size1
menu font bgcolor gray
menu shape potionbg 5 5 280 65 3 7 1 Black 7 Gray
menu font align right
menu text title 130 12 Resource Container:
menu text title 130 42 Potion Container:
menu font bgcolor silver
menu font align left
menu button target_resource_bag 230 10 30 24 Set
menu button target_dump_bag 230 40 30 24 Set
menu edit resource_bag 135 10 85 %resource_bag
menu edit dump_bag 135 40 85 %dump_bag
menu button start 170 75 55 25 Start
menu button quit 230 75 55 25 Quit
menu font size 9
menu font color marron
menu text titles 20 80 Select Type
menu text titles 115 80 Amount
menu button add_more 175 105 20 20 +
menu button remove 200 105 20 20 -
menu font size 8
menu font color black
menu combo create %pot_to_make 5 %size2 100
menu combo add %pot_to_make Total Refreshment
menu combo add %pot_to_make Greater Agility
menu combo add %pot_to_make Night Sight
menu combo add %pot_to_make Greater Heal
menu combo add %pot_to_make Greater Strength
menu combo add %pot_to_make Poison
menu combo add %pot_to_make Greater Poison
menu combo add %pot_to_make Deadly Poison
menu combo add %pot_to_make Greater Cure
menu combo add %pot_to_make Greater Explosion
menu combo add %pot_to_make Greater Conflagration
menu combo add %pot_to_make Greater Confusion Blast
menu combo add %pot_to_make Invisibility
menu combo add %pot_to_make Parasitic
menu combo add %pot_to_make Darkglow
menu edit %amount_to_make 110 %size2 50 0
menu show
gosub TM_GetPersistantVariable resource_bag
menu set resource_bag #result
menu get resource_bag
set %ResourceChest #menures
set #lobjectid %ResourceChest
event macro 17 0
wait 10
contpos 610 440
wait 10
gosub TM_GetPersistantVariable dump_bag
menu set dump_bag #result
menu get dump_bag
menuloop:
if #menuButton = target_resource_bag
{
set #targCurs 1
set_resource_bag:
if #targCurs = 1
goto set_resource_bag
Set %resource_bag #ltargetid
Set #lobjectid %resource_bag
Event Macro 17 0
wait 10
contpos 610 440
wait 10
menu font size 10
menu set resource_bag %resource_bag
gosub TM_SetPersistantVariable resource_bag %resource_bag
set #menubutton N/A
}
if #menuButton = target_dump_bag
{
set #targCurs 1
set_dump_bag:
if #targCurs = 1
goto set_dump_bag
Set %dump_bag #ltargetid
menu font size 10
menu set dump_bag %dump_bag
gosub TM_SetPersistantVariable dump_bag %dump_bag
set #menubutton N/A
}
if #menubutton = add_more
{
gosub add_more
set #menubutton N/A
}
if #menubutton = remove
{
gosub remove
set #menubutton N/A
}
if #menubutton = Start
{
set #menubutton N/A
set %size2 100
set %pot_to_make 100
set %amount_to_make 200
gosub loop
}
if #menubutton = Quit
{
set #menubutton N/A
display ok Thank you for using my script.$
+$
+Script is Halting$
menu hide
halt
}
goto menuloop
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXX SUB TO ADD ANOTHER OPTION XXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub add_more
set %size1 ( %size1 + 25 )
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
menu window size 290 %size1
menu font size 8
menu font color black
menu combo create %pot_to_make 5 %size2 100
menu combo add %pot_to_make Total Refreshment
menu combo add %pot_to_make Greater Agility
menu combo add %pot_to_make Night Sight
menu combo add %pot_to_make Greater Heal
menu combo add %pot_to_make Greater Strength
menu combo add %pot_to_make Poison
menu combo add %pot_to_make Greater Poison
menu combo add %pot_to_make Deadly Poison
menu combo add %pot_to_make Greater Cure
menu combo add %pot_to_make Greater Explosion
menu combo add %pot_to_make Greater Conflagration
menu combo add %pot_to_make Greater Confusion Blast
menu combo add %pot_to_make Invisibility
menu combo add %pot_to_make Parasitic
menu combo add %pot_to_make Darkglow
menu edit %amount_to_make 110 %size2 50 0
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXXX SUB TO REMOVE AN OPTION XXXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub remove
if %pot_to_make = 100
return
set %size1 ( %size1 - 25 )
set %size2 ( %size2 - 25 )
menu window size 290 %size1
menu delete %pot_to_make
menu delete %amount_to_make
set %pot_to_make ( %pot_to_make - 1 )
set %amount_to_make ( %amount_to_make - 1 )
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXXXXX MAIN LOOP FOR SCRIPT XXXXXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub loop
crafting_loop:
gosub clear_pack
gosub check_tool %alch_tool %alch_tools_needed %catposx 110 %selposx 90
gosub check_tool %tink_tool %tink_tools_needed %catposx 110 %selposx 130
gosub potion_init
gosub grab_resources %bottle %reagent1 %reagent2
gosub craft_potion %alch_tool %alch_tools_needed %catposx %catposy %selposx %selposy
goto crafting_loop
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXX SUB TO FIND AND RETURN RESOURCES XXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub clear_pack
finditem %resources C_ , #backpackid
for %i 1 #findcnt
{
finditem %resources C_ , #backpackid
exevent drag #findid #findstack
wait 10
exevent dropc %resource_bag
wait 15
}
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXX SUB TO CHECK AND CRAFT TOOLS XXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub check_tool
finditem %1 C_ , #backpackid
if #findcnt >= %2
return
set %to_make ( %2 - #findcnt ) ; Sets a number of tools to make
set #lobjectid #findid
; --------------------------------
; This section looks for ingots, then pulls 100
finditem %ingot_type C_ , %resource_bag
for #findindex 1 #findcnt
{
event property #findid
if copper || shadow || bronze || agapite || gold || verite || valorite in #property
ignoreitem #findid
if ingots in #property && shadow notin #property
set %ingots #findid ; Finds only Iron Ingots
}
finditem %ingots C_ , %resource_bag
if #findcnt < 20
{
display ok You are out of ingots.$
+Please get more and resetart script.
gosub clear_pack
halt
}
finditem %ingots C_ , %resource_bag
exevent drag #findid 100
wait 10
exevent dropc #backpackid
wait 15
; --------------------------------
; Makes tool required, and loops %to_make (number of tools needed) times
event macro 22 0
gosub gumpwait
set %x #contposx + %3
set %y #contposy + %4
click %x %y ; Selects Category
gosub gumpwait
for %i 1 %to_make
{
set %x #contposx + %5
set %y #contposy + %6
click %x %y ; Selects Tool
gosub gumpwait
}
gosub clear_pack
finditem %1 C_ , #backpackid
if #findcnt < %2
gosub check_tool
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXX SETS ITEMS NEEDED FOR EACH POTION XXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub potion_init
menu get %pot_to_make
if #menuRes = 1 ; Total Refreshment
{
set %reagent1 KUF ; Black Pearl
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 90
set %selposy 90
menu getnum %amount_to_make
set %amount #menures
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
}
if #menuRes = 2 ; Greater Agility
{
set %reagent1 JUF ; Bloodmoss
set %reagent2 N/A ; N/A
set %required_reagent1 3
set %required_reagent2 N/A
set %catposy 110
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 3 ; Night Sight
{
set %reagent1 RZF ; Spider's Silk
set %reagent2 N/A ; N/A
set %required_reagent1 1
set %required_reagent2 N/A
set %catposy 130
set %selposy 70
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 4 ; Greater Heal
{
set %reagent1 JZF ; Ginseng
set %reagent2 N/A ; N/A
set %required_reagent1 7
set %required_reagent2 N/A
set %catposy 150
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 5 ; Greater Strength
{
set %reagent1 MZF ; Mandrake Root
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 170
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 6 ; Poison
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 2
set %required_reagent2 N/A
set %catposy 190
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 7 ; Greater Poison
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 4
set %required_reagent2 N/A
set %catposy 190
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 8 ; Deadly Poison
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 8
set %required_reagent2 N/A
set %catposy 190
set %selposy 130
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 9 ; Greater Cure
{
set %reagent1 KZF ; Garlic
set %reagent2 N/A ; N/A
set %required_reagent1 6
set %required_reagent2 N/A
set %catposy 210
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 10 ; Greater Explosion
{
set %reagent1 WZF ; Nightshade
set %reagent2 N/A ; N/A
set %required_reagent1 10
set %required_reagent2 N/A
set %catposy 230
set %selposy 110
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 11 ; Greater Conflagration
{
set %reagent1 TZF ; Grave Dust
set %reagent2 N/A ; N/A
set %required_reagent1 10
set %required_reagent2 N/A
set %catposy 250
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 12 ; Greater Confusion Blast
{
set %reagent1 YZF ; Pig Iron
set %reagent2 N/A ; N/A
set %required_reagent1 10
set %required_reagent2 N/A
set %catposy 250
set %selposy 130
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 13 ; Invisibility
{
set %reagent1 JUF ; Bloodmoss
set %reagent2 WZF ; Nightshade
set %required_reagent1 4
set %required_reagent2 3
set %catposy 270
set %selposy 70
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 14 ; Parasitic
{
set %reagent1 YWS ; Parasitic Plant
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 270
set %selposy 90
menu getnum %amount_to_make
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
set %amount #menures
}
if #menuRes = 15 ; Darkglow
{
set %reagent1 XWS ; Luminescent Fungi
set %reagent2 N/A ; N/A
set %required_reagent1 5
set %required_reagent2 N/A
set %catposy 270
set %selposy 110
menu getnum %amount_to_make
set %amount #menures
if #menures = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
}
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXX SUB TO FIND AND GRAB RESOURCES XXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub grab_resources
if %amount >= 100
{
set %grab 100
}
if %amount < 100
{
set %grab %amount
}
; Finds and grabs Bottles
repeat
finditem %bottle C_ , %resource_bag
exevent drag #findid %grab
wait 10
exevent dropc #backpackid
wait 15
until #findcnt >= %grab
; Finds and grabs Reagent #1
repeat
finditem %1 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
until #findcnt >= 1000
; Finds and grabs Reagent #2
finditem %2 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
return
sub grab_more_resources
; Finds and grabs Reagent #1
finditem %1 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
; Finds and grabs Reagent #2
finditem %2 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXXXXX SUB FOR MAKING THE POTIONS XXXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub craft_potion
repeat
finditem %reagent1 C_ , #backpackid
if #findcnt < %required_reagent
gosub grab_more_resources %reagent1
finditem %1 C_ , #backpackid
if #findcnt < %2
gosub check_tool %alch_tool %alch_tools_needed %catposx 110 %selposx 90
event macro 22 0
gosub gumpwait
set %x #contposx + %3
set %y #contposy + %4
click %x %y ; Category
gosub gumpwait
set %x #contposx + %5
set %y #contposy + %6
click %x %y ; Selection (Potion)
gosub gumpwait
finditem %bottle C_ , #backpackid
until #findcnt = 0
gosub clear_pack
set %amount ( %amount - %grab )
if %amount = 0
{
menu delete %amount_to_make
menu font color red
menu text done 120 %size2 Done!
set %size2 ( %size2 + 25 )
set %pot_to_make ( %pot_to_make + 1 )
set %amount_to_make ( %amount_to_make + 1 )
return
}
return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXX GUMP WAIT SUB, ENSURES GUMP IS UP XXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub gumpwait
set %timer #SCNT + 5
repeat
until #CONTNAME = generic_gump || #SCNT > %timer
if #contname <> generic_gump
{
event macro 17 0
}
Return
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXX TRAILMYX'S PERSISTANT VARIABLE SUBS XXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub TM_GetPersistantVariable
set #RESULT %1 , _ , #CHARID
set #RESULT * . #RESULT
return #RESULT
sub TM_SetPersistantVariable
set #RESULT %1 , _ , #CHARID
set * . #RESULT %2
return
Now in the Pull Resources Sub, I have ensured that it is detecting the amount to grab, AND that it knows its grabbing bottles. I have verified this with something like this after the line of code that designates it.
Display ok You have %bottle
Well, I know its not perfect, but it works and it tells me that the %amount and that %bottles both have values.
Now with that said, it gets down to sub pull_resources and just loops between the return and until over and over, not pulling the bottles out of the %resource_bag
Maybe I don't have the resource bag designated?
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
; XXXXX SUB TO FIND AND GRAB RESOURCES XXXXXX
; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sub grab_resources
if %amount >= 100
{
set %grab 100
}
if %amount < 100
{
set %grab %amount
}
; Finds and grabs Bottles
repeat
finditem %bottle C_ , %resource_bag
exevent drag #findid %grab
wait 10
exevent dropc #backpackid
wait 15
until #findcnt >= %grab
; Finds and grabs Reagent #1
repeat
finditem %1 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
until #findcnt >= 1000
; Finds and grabs Reagent #2
finditem %2 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
return
sub grab_more_resources
; Finds and grabs Reagent #1
finditem %1 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
; Finds and grabs Reagent #2
finditem %2 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
return
-
Ok, so my last attempt was bogus since I didn't test it. For this one, I tested with stacks of POF. Suppose you have 3 stacks of 100 and one stack of 50 (350 total), this sub will grab all stacks up to the amount you request.
sub grab_resource
set %amount_grabbed 0
set %source %1
set %dest %2
set %item %3
set %amount %4
set %amount_left %amount
while %amount_grabbed < %amount
{
finditem %item C_ , %source
if #FINDKIND <> -1
{
if #FINDSTACK < %amount_left
set %drag_amount #FINDSTACK
else
set %drag_amount %amount_left
exevent drag #FINDID %drag_amount
wait 10
exevent dropc %dest
wait 20
set %amount_grabbed %amount_grabbed + %drag_amount
set %amount_left %amount - %amount_grabbed
continue
}
break
}
return %amount_grabbed
My test code is:
set %resource_bag XXYYZZ1
set %test POF
gosub grab_resource %resource_bag #BACKPACKID %test 43
stop
I put two stacks (40 and 42) in container XXYYZZ1. This sub picked up the 40 stack first, then 3 of the 42 of the second stack for the required total.
Guadah, you really shouldn't try and move something that you didn't find; you should check first that you actually found something. Although I'm not saying it's going to crash anything, I think it's just cleaner programming to verify you found something before you start running exevent drag. Plus you need to remove your general assumption of the pile size, or "exevent drag #FINDID 1000", at least use "exevent drag #FINDID #FINDSTACK"
-
For the last code you posted, you need to remember the differences between #FINDCNT and #FINDSTACK. #FINDCNT tells you how many items you found, and #FINDSTACK tells you how big a stack that one found item is. So in your code:
repeat
finditem %1 C_ , %resource_bag
exevent drag #findid 1000
wait 10
exevent dropc #backpackid
wait 15
until #findcnt >= 1000
The only way this would work if you had 1000 individual pieces of reagent in a bag (actually, it still won't work..) That's why I had to do the little extra work in the sub I made so it handles both. So if you implement this:
gosub grab_resource %resource_bag #BACKPACKID %bottle 100
if #RESULT = 0
gosub RanOutOfBottles
gosub grab_resource %resource_bag #BACKPACKID %reagent1 1000
if #RESULT = 0
gosub RanOutOfReagents
gosub grab_resource %resource_bag #BACKPACKID %reagent2 1000
if #RESULT = 0
gosub RanOutOfReagents
...
stop
;-------------------------------------
sub grab_resource
set %amount_grabbed 0
set %source %1
set %dest %2
set %item %3
set %amount %4
set %amount_left %amount
while %amount_grabbed < %amount
{
finditem %item C_ , %source
if #FINDKIND <> -1
{
if #FINDSTACK < %amount_left
set %drag_amount #FINDSTACK
else
set %drag_amount %amount_left
exevent drag #FINDID %drag_amount
wait 10
exevent dropc %dest
wait 20
set %amount_grabbed %amount_grabbed + %drag_amount
set %amount_left %amount - %amount_grabbed
continue
}
break
}
return %amount_grabbed
This will grab 100 bottles possibility in multiple piles, and 2 different reagents also in many possible piles until you run out of something.
-
Ahh I didn't think about that. Thanks for the update to the post TM. When the servers get back up, I'll adjust the needed modifications and give it a test run.
I also found out that earlier in the script I designated the Resources Chest as %ResourceChest, yet later I was calling for %resource_bag so thats why I wasn't even getting a response, because it was not looking inside of any bag at all.
Thanks for the update brother, you as always are a true help!
-
I did get the script working :D yay!
Now Thank you TM for your advice and suggestions. I didn't use what you posted, but I did learn from it. I was being stubborn in the area of wanting to make what I wrote out of my head work. I hope you understand?
I have not updated the pull_resources part to pull 10 from two stacks of 7 and 5 yet, as you previously suggested in the code above, but I will. However, the script is working, and I have successfully made 15 different potions in a row all in one sitting. I'm very happy with the results.
Thanks again TM.
-
so is there a finished product that we can download? I would like to try this out
-
I was just wondering if smoke bombs will ever been added to this script?
-
Guadah is basically inactive in uo atm . I don't see it happening. Would it be helpful if i added tehm to my cooking script? or did u need them to be made through alchy
-
I don't have a cook, or I didn't know they could be made through cooking as well.