ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Crisis on January 02, 2014, 03:31:54 PM
-
First thing is my checkboards sub. It is filling boards everytime regardless of how many boards are in my pack.
sub CheckBoards
menu delete scriptstatus
menu text scriptstatus 95 100 Checking Boards
finditem %boards C_ , #backpackid
if #findcnt < 20
{
menu delete scriptstatus
menu text scriptstatus 95 100 Moving Boards
gosub moveit #backpackid %ResourceSecure %boards 200
gosub hardwait %postregmovewait
if #result = 0
{
display ok Out of boards in secure, halting...
halt
}
}
return
I may be wrong but it is supposed to find my boards, if I have less than 20 it is supposed to restock. Right now it restocks at every check which overloads me.
I am also not getting my script to target breakable carpentry items and use a axe on them
sub CheckWeight
Set %WeightMargin #MaxWeight - #Weight
finditem %garbage C_ , #backpackid
If #FindCnt > 0 && %WeightMargin < 50
finditem %garbage C_ , #backpackid
If #FindCnt > 0
{
For %dumpgarbage 1 #FindCnt
{
Set #FindIndex %dumpgarbage
exevent drag #findid #findstack
wait 10
exevent dropc %TrashBarrel
wait 10
}
}
finditem %BreakGarbage
if #findkind = 0
{
return
}
set %breakthis #findid
Breakit:
set #lobjectid %axetype
event macro 17 0
target 4s
set #ltargetid %breakthis
set #ltargetkind 1
event macro 22 0
wait %gumpwait
finditem %breakthis
if #findkind = 0
Return
Grrrrr so frustrating! I am sure it is small things that I have over looked.
I am adding the entire script in case it is needed
;===================================================================
set #lpc 200
; contpos warning: be sure to manually open
; and move tinkering/carpentry gumps to
; desired location in order to get them to 'stick' there...
; manually set desired open container/gump screen coords
set %menux 800
set %menuy 0
set %journalx 850
set %journaly 420
set %skillx 1100
set %skilly 0
set %statusx 0
set %statusy 700
set %backpackx 650
set %backpacky 450
set %resourcex 475
set %resourcey 450
; runuo or osi -> #true or #false
set %runuo #false
; manually set secure cotainer ID's, or leave blank (or N/A) for automated setup
set %ResourceSecure NACAPQD
;===================================================================
gosub constants
gosub drawmenu
while #true
{
gosub #menubutton
gosub *request
}
;===================================================================
sub drawmenu
Menu Window Title Crisis Carpentry Trainer
Menu Window Color Lime
Menu Window Size 270 155
Menu Font BGColor Silver
Menu Font Color Maroon
menu shape skillsbg 5 5 260 85 3 7 1 Silver 7 Black
menu shape statusbg 5 95 260 25 3 7 1 Silver 7 Black
Menu Font Size 10
Menu Font Align Right
Menu Font Color Lime
menu font bgcolor Black
Menu Text Titles 85 10 Carpentry:
Menu Text Titles 85 30 Attempts:
Menu Text Titles 85 50 Time:
Menu Text Titles 85 70 Last Gain:
Menu Text Titles 85 100 Status:
Menu Font Align Left
chooseskill carp real
set %startingskill #skill
set %currentskill #skill
str len %currentskill
str ins %currentskill #dot #strRes
menu text currentskill 95 10 #strRes
set %totalgains %currentskill - %startingskill
str len %totalgains
str ins %totalgains #dot #strRes
menu Text totalgains 130 10 + #strRes
Set %Attempts 0
Menu Text Attempts 95 30 %Attempts
Set %start_time #scnt
set %hours 00
set %mins 00
set %secs 00
Set %total_time %hours , : , %mins , : , %secs
Set %last_gain %hours , : , %mins , : , %secs , #spc , %ap
menu Text TotalTime 95 50 %total_time
menu Text LastGain 95 70 %last_gain
menu Font BGColor
menu Font Color Lime
menu Button StartP 40 125 75 25 Start
menu Font Color Lime
menu Button QuitP 152 125 75 25 Quit
Menu Font Size 10
Menu Font Color Lime
menu font bgcolor Black
menu delete scriptstatus
menu text scriptstatus 95 100 Click "Start" to begin.
menu show %menux %menuy
Set #menuButton N/A
return
;===================================================================
sub DelStart
menu Delete StartP
menu font bgcolor Black
menu font color Lime
menu Button PauseP 40 125 75 25 Pause
return
;===================================================================
sub DelPause
Menu Delete PauseP
Menu Font Color Lime
menu font bgcolor Black
Menu Button ResumeP 40 125 75 25 Resume
return
;===================================================================
sub DelResume
Menu Delete ResumeP
Menu Font Color Lime
menu font bgcolor Black
Menu Button PauseP 40 125 75 25 Pause
Return
;===================================================================
sub StartP
gosub DelStart
set #menubutton N/A
set *request INIT
return
;===================================================================
sub PauseP
gosub DelPause
menu delete scriptstatus
Menu Font Color Red
menu font bgcolor Black
menu text scriptstatus 95 100 Paused
set #menubutton N/A
set *request IDLE
return
;===================================================================
sub ResumeP
gosub DelResume
set #menubutton N/A
if %initialized
set *request CRAFT
else
set *request INIT
return
;===================================================================
sub QuitP
set *request END
return
sub Closed
set *request END
return
;===================================================================
sub INIT
set *state INIT
gosub ScriptBegin
set *request CRAFT
return
;===================================================================
sub CRAFT
set *state CRAFT
gosub %s . *substate
set *substate ( *substate + 1 ) % 5
return
;===================================================================
sub IDLE
; do nothing
set *state IDLE
gosub hardwait 1
return
;===================================================================
sub END
set *state END
display ok Thank you for using Crisis Carpentry Trainer.$
+$
+Script is Halting$
menu hide
menu clear
halt
return
;===================================================================
sub ScriptBegin
set %lastitemindex 0
gosub setup
gosub ClearPackBoards %boards
gosub ClearPackGarbage %garbage
return
;===================================================================
sub hardwait
if ( %0 = 0 ) || ( %1 = 1 )
{
sleep 10
return
}
wait %1
return
;===================================================================
sub contidwait
set %_gid %1
set %_tm #systime + ( %gumptimeout * 50 )
gosub hardwait %gumpwait
while %_gid <> #contid
{
wait 1
if #systime > %_tm
{
display ok Timeout waiting for container id %1 to open.
+$ Pausing.
+$ Manually open container, then hit run button on main easyuo window to resume script.
pause
if #contid <> %_gid
return #false
}
}
return #true
;===================================================================
sub setup
menu delete scriptstatus
menu text scriptstatus 95 100 Setting Up Script
;open journal
event macro 8 3
gosub hardwait %precontposwait
contpos %journalx %journaly
gosub hardwait %postcontposwait
;open skills
gosub actionblock
event macro 8 4
gosub hardwait %precontposwait
contpos %skillx %skilly
gosub hardwait %postcontposwait
;open status
gosub actionblock
event macro 8 2
gosub hardwait %precontposwait
contpos %statusx %statusy
gosub hardwait %postcontposwait
;open backpack
gosub actionblock
event macro 8 7
gosub contidwait #backpackid
contpos %backpackx %backpacky
gosub hardwait %postcontposwait
gosub CountRegs
set %mana 0
; locate/open resource secure
str len %ResourceSecure
if ( N/A notin %ResourceSecure ) && ( #strres > 0 )
{
finditem %ResourceSecure
if #findkind <> -1
goto _openres
}
_selres:
display Ok Select your Resource Container.
set #targcurs 1
while #targcurs = 1
gosub hardwait 2
set %ResourceSecure #ltargetid
_openres:
set #lobjectid %ResourceSecure
gosub actionblock
event macro 17 0
gosub contidwait %ResourceSecure
contpos %resourcex %resourcey
gosub hardwait %postcontposwait
; locate trash barrel
Display Ok Select the trash barrel.
set #targcurs 1
while #targcurs = 1
gosub hardwait 2
set %Trashbarrel #ltargetID
wait 20
set %initialized #true
return
;===================================================================
sub constants
if %runuo
{
set %cwin 530_437 ; Carpentry window size
set %tinkwin 530_437 ; Tinkering window size
set %texitx 30
set %texity 410
set %tmlx 280
set %tmly 410
set %ttoolsx 30
set %ttoolsy 110
set %ttinkx 230
set %ttinky 130
set %tsawx 230
set %tsawy 210
set %cexitx 30
set %cexity 410
set %cmlx 280
set %cmly 410
set %in ItemRUO
}
else
{
; EA OSI
set %cwin 530_497 ; 530_437 ; Carpentry window size
set %tinkwin 530_497 ; 530_437 ; Tinkering window size
set %carpentry carp
; Materials
set %ingots ENK
set %boards TLK
set %tinkertool JTL_GTL_KTL
set %carptool YFG_ZHG_CIG_BIG_AGG_EGG_AIG_WFG_IGG_KGG_ZFG_CGG
set %axeType LSF_OSF_NSF_BSF_MSF_CSF_ISF_MPH_JOH_UOH_RMH_LPH_ZRF
set %garbage BTL_OJL_OIK_MDP_ZPF_DMH_GFF_BFR
set %breakgarbage VMF_UMF
; Items to make
set %Item1 BTL ; Barrel Staves
set %Item2 OJL ; Barrel Lid
set %Item3 VMF ; Medium Crate
set %Item4 UMF ;Crossbow
set %Item5 OIK ; Wooden Shield
set %Item6 MDP ; Fukiya
set %Item7 ZPF ; Quarter Staff
set %Item8 DMH ; Sheppard's Crook
set %Item9 GFF ; Black Staff
set %Item10 BFR ; Wild Staff
; max skill threshold for each item
set %Threshold1 200
set %Threshold2 320
set %Threshold3 480
set %Threshold4 530
set %Threshold5 600
set %Threshold6 740
set %Threshold7 790
set %Threshold8 820
set %Threshold9 960
set %Threshold10 100
; CRAFT substates
set %s0 CheckTinkerTools
set %s1 CheckCarpTools
set %s2 CheckBoards
set %s3 SkillCraft
set %s4 DumpGarbage
; Timing tweaks. 20 = 1 second
set %gumpwait 1 ; Time to wait before scanning for open gump/container
set %gumptimeout 60 ; Maximum amount of time to wait for gump to open
set %precontposwait 10 ; Time to wait after opening gump and moving it using contpos
set %postcontposwait 30 ; Time to wait after performing contpos
set %postdropwait 22 ; Time to wait after each exevent drop before attempting any other action
set %postcraftwait 1 ; Time to wait after an item is crafted before performing any other action
set %preregmovewait 10 ; Minimum time to wait before moving all regs
set %postregmovewait 22 ; Extra time to wait after moving all regs, (in addition to %postdropwait, above)
set %interactiontime 10 ; Minimum measured interval between all { exevent drop, event macro } operations
set %_lit %interactiontime * 20
set %_lastactiont #systime - %_lit
; initial states
set %initialized #false
set *substate 0
set *state IDLE
set *request IDLE
return
;===================================================================
sub ClearPackBoards
menu delete scriptstatus
Menu Font BGColor Black
menu Font Color Lime
menu text scriptstatus 95 100 Clearing Pack of Boards
finditem %boards C_ , #backpackid
if #findcnt < 1
return
for #findindex 1 #findcnt
{
exevent drag #findid #findstack
wait 20
exevent dropc %ResourceSecure
wait 20
}
return
;===================================================================
sub ClearPackGarbage
menu delete scriptstatus
Menu Font BGColor Black
menu Font Color Lime
menu text scriptstatus 95 100 Clearing Pack of Garbage
{
finditem %Garbage C_ , #backpackid
if #findcnt > 0
}
for %ItemToDump 1 #findcnt
{
Set #FindIndex %ItemToDump
exevent drag #findid #findstack
wait 20
exevent dropc %Trashbarrel
wait 20
}
return
;===================================================================
sub CheckTinkerTools
menu delete scriptstatus
Menu Font BGColor Black
menu Font Color Lime
menu text scriptstatus 95 100 Getting New Tinker Tool
finditem %tinkertool C_ , #backpackid
if #findcnt < 2
gosub MakeTinkerTools
return
;===================================================================
sub CheckCarpTools
menu delete scriptstatus
Menu Font BGColor Black
menu Font Color Lime
menu text scriptstatus 95 100 Getting New Carpenter's Tool
; keep two in pack in case current one gets worn out
finditem %carptool C_ , #backpackid
if #findcnt < 2
gosub MakeCarpTools
return
;===================================================================
sub CheckBoards
menu delete scriptstatus
menu text scriptstatus 95 100 Checking Boards
finditem %boards C_ , #backpackid
if #findcnt = 0
{
menu delete scriptstatus
menu text scriptstatus 95 100 Moving Boards
gosub moveit #backpackid %ResourceSecure %boards 200
gosub hardwait %postregmovewait
if #result = 0
{
display ok Out of boards in secure, halting...
halt
}
}
return
;if #findstack < ( 30 * %craftingboards )
;{
;Set %boardsneeded %craftingboards * 30 - #FindStack
;Gosub moveit #BackpackID %ResourceSecure %boardsneeded
;}
return
;===================================================================
sub MakeTinkerTools
menu delete scriptstatus
Menu Font BGColor Black
menu Font Color Lime
menu text scriptstatus 95 100 Making New Tinker Tool
finditem %ingots C_ , #backpackid
if #findstack >= 25
goto _maketink
set %_diff 25 - #findstack
finditem %ingots C_ , %ResourceSecure
if #findstack < 25
{
display You have used up most of your ingots. Halting...
set *request END
}
gosub moveit #backpackid %ResourceSecure #findid %_diff
_maketink:
finditem %tinkertool C_ , #backpackid
if #FindCnt = 0
{
display You are out of tinker tools. Get a tinker tool and restart script.
halt
}
set #lobjectID #findid
gosub actionblock
event macro 17 0
gosub tinkwait
gosub offsetclick 27 130 ; tools
wait 5
gosub tinkwait
gosub offsetclick 230 130 ; tinker's tools
wait %postcraftwait
gosub offsetclick 27 450 ; exit
finditem %tinkertool c_ , #backpackid
if #findcnt < 2
gosub MakeTinkerTools
return
;===================================================================
sub MakeCarpTools
menu delete scriptstatus
Menu Font BGColor Black
menu Font Color Lime
menu text scriptstatus 95 100 Getting New Carpenter's Tool
finditem %ingots C_ , #BackpackID
if #findstack >= 25
goto _makecarptool
set %_diff 25 - #findstack
finditem %ingots C_ , %ResourceSecure
if #findstack < 25
{
display You have used up most of your ingots. Halting...
set *request END
return
}
gosub moveit #backpackid %ResourceSecure #findid %_diff
_makecarptool:
finditem %tinkertool C_ , #Backpackid
if #findcnt = 0
{
display You are out of tinker tools. Get a tinker tool and restart script.
set *request END
return
}
_makecarptool:
finditem %tinkertool C_ , #Backpackid
if #findcnt = 0
{
display You are out of tinker tools. Get a tinker tool and restart script.
halt
}
set #lobjectID #Findid
gosub actionblock
event macro 17 0
gosub tinkwait
gosub offsetclick 27 130 ; tools
wait 5
gosub tinkwait
gosub offsetclick 235 210 ; saw
wait 5
gosub tinkwait
gosub offsetclick 280 450 ; make last
wait 5
gosub offsetclick 25 450 ; exit
finditem %carptool c_ , #backpackid
if #findcnt < 2
gosub MakeCarpTools
return
;===================================================================
sub actionblock
while #systime < %_lastactiont
{
set %_sl %_lastactiont - #systime - 10
if %_sl > 0
sleep %_sl
}
set %ji #jindex + 1
set %_lastactiont #systime + %_lit
return
;===================================================================
sub SkillCraft
menu delete scriptstatus
Menu Font BGColor Black
menu Font Color Lime
menu text scriptstatus 95 100 Attempting Skill Gains
gosub Calc_Time
gosub carptoolwait
if true in #result
goto _menu_up
_getcarptool:
finditem %carptool C_ , #Backpackid
if #findcnt < 2
{
return
}
set #lobjectid #findid
gosub actionblock
event macro 17
gosub carptoolwait
if getcarptool in #result
{
goto _getcarptool
}
if false in #result
{
gosub carptoolwait
}
if true notin #result
{
goto _getcarptoolItem
}
wait 20
_menu_up:
chooseskill carp real
set %CurrentSkill #Skill
gosub SkillCheck
if %lastitemindex <> %itemindex
{
gosub Item . %itemindex
gosub ClickItem
gosub hardwait %postcraftwait
gosub carptoolwait
if getcarptool in #result
goto _getcarptool
set %lastitemindex %itemindex
if false in #result
goto _getcarptool
}
gosub offsetclick 280 450 ; make last
gosub hardwait %postcraftwait
gosub carptoolwait
;gosub CheckWeight
gosub CheckBoards
wait 10
gosub AddAttempts
gosub MenuSkillCheck
gosub Calc_Time
return
;===================================================================
sub ClickItem
for %a 1 %numclick
{
_clickagain:
gosub offsetclick %XClick . %a %YClick . %a
gosub carptoolwait
if true notin #result
return #result
}
return true
;===================================================================
sub Skillcheck
chooseskill carp real
for %a 1 10
{
if #skill < ( %Threshold . %a )
{
set %itemindex %a
return
}
}
display Congratulations, #charname you are the newest GM Carpenter. Skillcap reached, halting.
halt
return
;===================================================================
sub Item1 ; Barrel Stave
set %CraftingBoards 5
set %XClick1 30 ; other
set %YClick1 90
set %XClick2 235 ;barrel stave
set %YClick2 70
set %numclick 2
Return
;===================================================================
sub Item2 ; Barrel Lid
set %CraftingBoards 4
set %XClick1 30 ; other
set %YClick1 90
set %XClick2 235 ; barrel lid
set %YClick2 90
set %numclick 2
Return
;===================================================================
sub Item3 ; Medium Crate
set %CraftingBoards 15
set %XClick1 30 ; container
set %YClick1 130
set %XClick2 235 ; medium crate
set %YClick2 110
set %numclick 2
Return
;===================================================================
sub Item4 ; Large Crate
set %CraftingBoards 18
set %XClick1 30 ; container
set %YClick1 130
set %XClick2 235 ; large crate
set %YClick2 130
set %numclick 2
Return
;===================================================================
sub Item5 ; Wooden Shield
set %CraftingBoards 9
set %XClick1 30 ; armor
set %YClick1 170
set %XClick2 235 ; wooden shield
set %YClick2 70
set %numclick 2
Return
;===================================================================
sub Item6 ; Fukiya
set %CraftingBoards 8
set %XClick1 30 ; weapon
set %YClick1 150
set %XClick2 235 ; fuliya
set %YClick2 150
set %numclick 2
Return
;===================================================================
sub Item7 ; Quarter Staff
set %CraftingBoards 6
set %XClick1 30 ; weapon
set %YClick1 150
set %XClick2 235 ; quarter staff
set %YClick2 90
set %numclick 2
Return
;===================================================================
sub Item8 ; Sheppard Crook
set %CraftingBoards 7
set %XClick1 30 ; weapon
set %YClick1 150
set %XClick2 235 ; sheppard's crook
set %YClick2 70
set %numclick 2
Return
;===================================================================
sub Item9 ; Black Staff
set %CraftingBoards 9
set %XClick1 30 ; weapon
set %YClick1 150
set %XClick2 380 ; next page
set %YClick2 270
set %XClick3 235 ; black staff
set %YClick3 170
set %numclick 3
Return
;===================================================================
sub Item10 ; Wild Staff
set %CraftingBoards 16
set %XClick1 30 ; weapon
set %YClick1 150
set %XClick2 235 ; wild staff
set %YClick2 190
set %numclick 2
Return
;===================================================================
sub GumpWait
set %_tm #systime + ( %gumptimeout * 50 )
gosub hardwait %gumpwait
while #contsize <> %cwin
{
sleep 10
if #systime > %_tm
{
display Problem waiting on craft gump, open manually then press play easyuo menu
pause
}
}
return #true
;===================================================================
sub carptoolwait
set %_t #systime
set %_tm #systime + ( %gumptimeout * 20 )
gosub hardwait %gumpwait
while #contsize <> %cwin
{
sleep 10
if #jindex >= %ji
{
for %_a %ji #jindex
{
scanjournal %_a
if worn_out in #journal
{
return getcarptool
}
set %ji %ji + 1
}
}
if #systime > %_tm
{
return false
}
}
set %_t #systime - %_t
return true
;===================================================================
sub tinkwait
set %_tm #systime + ( %gumptimeout * 20 )
gosub hardwait %gumpwait
while #contsize <> %tinkwin
{
sleep 10
if #systime > %_tm
{
display Problem waiting on tinkering gump, open manually then press play on easyuo menu
pause
}
}
return #true
;===================================================================
sub offsetclick
set %_tempx #contposx + %1
set %_tempy #contposy + %2
if %0 > 2
click %_tempx %_tempy %3
else
click %_tempx %_tempy
return
;===================================================================
sub CheckWeight
Set %WeightMargin #MaxWeight - #Weight
finditem %garbage C_ , #backpackid
If #FindCnt > 0 && %WeightMargin < 50
finditem %garbage C_ , #backpackid
If #FindCnt > 0
{
For %dumpgarbage 1 #FindCnt
{
Set #FindIndex %dumpgarbage
exevent drag #findid #findstack
wait 10
exevent dropc %TrashBarrel
wait 10
}
}
finditem %BreakGarbage
if #findkind = 0
{
return
}
set %breakthis #findid
Breakit:
set #lobjectid %axetype
event macro 17 0
target 4s
set #ltargetid %breakthis
set #ltargetkind 1
event macro 22 0
wait %gumpwait
finditem %breakthis
if #findkind = 0
Return
;===================================================================
sub moveit
menu delete scriptstatus
Menu Font BGColor Black
menu Font Color Lime
menu text scriptstatus 95 100 Moving Items
; %1 destination container ID
; %2 source container ID, or * (any except destination), or # (ground)
; %3 specific item types to move, or * (all found items)
; %4 optional, stacksize
set %_max 60000
set %_total 0
if %0 = 4
set %_max %4
set %_from C_ , %2
if * in %2
set %_from C
if # in %2
set %_from G_2
finditem %3 %_from
if #findkind = -1
return %_total
set %pd _NULL_
if * in %2
set %pd #charid
for #findindex 1 #findcnt
{
if ( #findbagid <> %1 ) && ( #findbagid <> %pd )
{
set %_amt %_max
if #findstack < %_max
set %_amt #findstack
set %_total %_total + %_amt
gosub actionblock
exevent drag #findid %_amt
gosub hardwait
if %1 = #charid
exevent droppd
else
exevent dropc %1
gosub hardwait %postdropwait
}
}
return %_total
;===================================================================
Sub Calc_Time
Set %TT #Scnt - %start_time
Set %hours %TT / 3600
Set %mins ( %TT / 60 ) - ( %hours * 60 )
Set %secs %TT % 60
If %hours =< 9
Set %hours 0 , %hours
If %mins =< 9
Set %mins 0 , %mins
If %secs =< 9
Set %secs 0 , %secs
Set %total_time %hours , : , %mins , : , %secs
Menu Font Color Black
Menu Font Size 10
menu set TotalTime %total_time
Return
;===================================================================
Sub AddAttempts
Set %attempts %attempts + 1
Menu Font Size 10
Menu Font Color Black
menu set Attempts %attempts
Return
;===================================================================
sub time
set %ap AM
set %time #time
str right %time 2
set %sec #StrRes
str left %time 2
set %hr #StrRes
str mid %time 3 2
set %min #StrRes
if %hr > 11 && %hr < 24
set %ap PM
if %hr > 12
set %hr ( %hr - 12 )
if %hr = 00
set %hr 12
set %last_gain %hr , : , %min , : , %sec , #spc , %ap
Menu Font Color Black
Menu Font Size 10
menu set LastGain %last_gain
return
;===================================================================
Sub MenuSkillCheck
chooseskill carp real
if #skill = #skillcap
{
set %currentskill #skill
menu set current %currentskill
wait 10
display You have reached your skill cap.$
+Thank you for using Crisis Carpentry Trainer$
+$
+Script is Halting$
menu hide
set *request END
return
}
if #skill > %currentskill
{
Set %currentskill #skill
str len %currentskill
str ins %currentskill #dot #strRes
Menu Font Size 10
Menu Font Color Lime
menu set currentskill #strRes
Set %totalgains %currentskill - %startingskill
str len %totalgains
str ins %totalgains #dot #strRes
menu set totalgains + #strRes
gosub time
}
Return
-
here, try this sub.
Gosub Resource (Secure) (Type) (Col) (Min) (Max)
You can set the Secure to N/A if you don't care what container it comes from, and you can set Color to N/A if you don't care about the color. If you are below the Minimum, it will restore you back to the maximum. It will return how many of the resource it grabbed with #Result, #Result will = Out if you are out of what you were looking for.
Can Try and help you debug it later, but this was the best I can do for now.
Sub Resource
; Gosub Resource (Secure) (Type) (Col) (Min) (Max)
Namespace Push
Namespace Local Mwinc_Resource
set !Cont_Id %1
set !Resource %2
set !Col %3
set !Min %4
set !Max %5
Finditem !Resource C_ , #backpackid
set !Amount 0
for #findindex 1 #findcnt
{
if #Findcol = !Col || !Col = N/A
set !Amount !Amount + #Findstack
}
if !Amount >= !Min
{
Namespace Pop
Return 0
}
set !Amount2 !Max - !Amount
if !Cont_id <> N/A
Finditem !Resource C_ , !Cont_Id
Else
Finditem !Resource C
if #findcnt > 0
{
For #findindex 1 #findcnt
{
if ( #findcol = !Col || !Col = N/A ) && #Findbagid <> #Backpackid
{
Exevent drag #Findid !Amount2
wait 15
Exevent dropc #backpackid
wait 15
set #Result !Amount2
Namespace Pop
Return #Result
}
}
}
Namespace Pop
Return Out
-
First thing is my checkboards sub. It is filling boards everytime regardless of how many boards are in my pack.
sub CheckBoards
menu delete scriptstatus
menu text scriptstatus 95 100 Checking Boards
finditem %boards C_ , #backpackid
if #findcnt < 20
{
menu delete scriptstatus
menu text scriptstatus 95 100 Moving Boards
gosub moveit #backpackid %ResourceSecure %boards 200
gosub hardwait %postregmovewait
if #result = 0
{
display ok Out of boards in secure, halting...
halt
}
}
return
#findcnt will be < 20 until you have 20 or more stacks of boards. Use #findstack.
I'll comment on the others in a minute.
X
-
Your missing brackets on your check weight sub... line 5 is where you should have the beginning bracket etc.
-
#findcnt will be < 20 until you have 20 or more stacks of boards. Use #findstack.
I'll comment on the others in a minute.
X
I can't believe that I missed that, I knew that the reason it was repeating was something small.
For the other part checkweight, I am thinking that I need to make that 2 subs, check wright for the garbage and then checkbackpackquantity to break the containers. The containers do not weight much and the bag fills up quick with it making them lockable.
-
Ah, yeah they summed it up. Just had the time to look over it.
-
Okay I separated them into 2 different subs, something is wrong with using the axe to destroy the crates though.
sub CheckWeight
Set %WeightMargin #MaxWeight - #Weight
find %garbage C_ , #backpackid
If #FindCnt > 0 && %WeightMargin < 100
{
finditem %garbage C_ , #backpackid
If #FindCnt > 0
{
gosub ClearPackGarbage
}
}
Return
sub CheckBackpackQuantity
finditem * C_ , #backpackid
set %totalcount #findcnt
if %totalcount > 100
{
finditem %BreakGarbage
if #findkind = 0
{
return
}
set %breakthis #findid
Breakit:
set #lobjectid %axetype
event macro 17 0
target 4s
set #ltargetid %breakthis
set #ltargetkind 1
event macro 22 0
wait %gumpwait
finditem %breakthis
if #findkind = 0
}
Return
;===================================================================
-
I also tried this as well
sub CheckBackpackQuantity
finditem * C_ , #backpackid
set %totalcount #findcnt
if %totalcount > 100
{
finditem %BreakGarbage
set %breakthis #findid
if #findkind = 0
{
return
}
Breakit:
finditem %axechopper C_ , #backpackid
set #lobjectid %axechopper
event macro 17 0
target 4s
set #ltargetid %breakthis
set #ltargetkind 1
event macro 22 0
wait %gumpwait
finditem %breakthis
if #findkind = 0
}
Return
-
1) finditem % breakgarbage..... where you looking..aka C_ , # backpacking
2) The last "If" statement only executes the following line without brackets..
3) I like to use #findcnt = 0. Instead of # findkind and I know there was a good reason why but I honestly forget..
-
1) finditem % breakgarbage..... where you looking..aka C_ , # backpacking
2) The last "If" statement only executes the following line without brackets..
3) I like to use #findcnt = 0. Instead of # findkind and I know there was a good reason why but I honestly forget..
I made those changes and it is chopping them up now. It's always the little things that get me lol. Thanks!
-
Np... glad it's working for ya.