ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: Crisis on February 26, 2013, 07:43:15 AM
-
I am using Polonius's Move Resource Sub. I have looked this over a ton of times but best as I can tell the checkpotash sub is showing to check for a stack >=500 and then to move that 500. It is moving 1 piece of potash to the resource container but leaving the stack >=500. What am I missing?
;=========================================
Start:
Gosub Setup
;===================Sub Setup============================
Sub Setup
set %TinkerTools JTL_GTL_KTL
Set %Tongs OBG
Set %Boards TLK
Set %MortarPestle RQF
Set %EmptyPitcher WYF
Set %FullPitcher VBM
Set %Potash AFZ
Set %SaveList NWH_RCG_FCG_FKF
Set %DumpList
set %Ingots ENK
set %cwin 530_497 ; Crafting window size
set %gumpwait 1 ; Increase number to slow down clicks on menus. 20 = 1 second.
set %targetcursorwait 1 ; Increase number as above
Display Ok Select the container with your resources in it.
set #targcurs 1
while #targcurs = 1
wait 1
set %ResourceSecure #ltargetID
set #lobjectID #ltargetID
set #nextcposx 400
set #nextcposy 0
event macro 17
wait 20
{
gosub mainmenu
}
return
;===================Sub Main Menu======================
sub MainMenu
menu Clear
menu Window Title Crisis High Seas Munitions Factory
menu Window Color $FFFFFFFF
menu Window Size 190 130
menu Font Transparent #true
menu Font Align Right
menu Font Name Comic Sans MS
menu Font Size 8
menu Font Style b
menu Font Color Lime
menu Font Transparent #false
menu Font Align Left
menu Font BGColor $FFFFFFFF
menu Text EUOLabel1 63 0 Select One:
menu Font Name MS Sans Serif
menu Font Style
menu Font Color WindowText
menu Font BGColor Window
menu Font BGColor Lime
menu Button begin 64 62 55 25 Start
menu Font Name Comic Sans MS
menu Font Style b
menu Font Color Lime
menu Font BGColor $FFFFFFFF
menu Font Name MS Sans Serif
menu Font Style
menu Font Color WindowText
menu Font BGColor Window
menu Combo Create list 20 16 150
menu Combo Add list Potash
menu Combo Add list Black Powder
menu Combo Add list Light Powder Charge
menu Combo Add list Heavy Powder Charge
menu Combo Add list Light Grapeshot
menu Combo Add list Light Cannonball
menu Combo Add list Heavy Grapeshot
menu Combo Add list Heavy Cannonball
menu Combo Add list Fuse Cord
menu Combo Add list Match Cord
menu Combo Add list Match
menu Combo Add list Swab
menu Combo Add list Ramrod
menu Show 421 270
set #menubutton N/A
repeat
until #menubutton <> N/A
menu delete begin
menu hide
menu get list
if #menures = 1
set %craftable Potash
if #menures = 2
set %craftable BlkPwdr
if #menures = 3
set %craftable LtPwdrChg
if #menures = 4
set %craftable HvyPwdrChg
if #menures = 5
set %craftable LtGrpSht
if #menures = 6
set %craftable LtCanBall
if #menures = 7
set %craftable HvyGrpSht
if #menures = 8
set %craftable HvyCanBall
;choosesitem %craftable
if %craftable = Potash
{
Display You must be next to a water trough and have a water pitcher in your backpack.
gosub MakePotash
}
if %craftable = BlkPwdr
{
gosub MakeBlackPowder
}
if %craftable = LtPwdrChg
{
gosub LightPowderCharge
}
if %craftable = HvyPwdrChg
{
gosub HeavyPowderCharge
}
if %craftable = LtGrpSht
{
gosub LightGrapeShot
}
if %craftable = LtCanBall
{
gosub LightCannonBall
}
if %craftable = HvyGrpSht
{
gosub HeavyGrapeShot
}
if %craftable = HvyCanBall
{
gosub HeavyCannonBall
}
until #charghost = yes
return
;===================Sub Make Potash===========================
Sub MakePotash
MakePotashLoop:
finditem %Boards C_ , #backpackid
if #findstack < 10
{
set %quantityinpack 100 - #findstack
Gosub Move_Resource_To_Container %Boards 0 %ResourceSecure #BackpackID %quantityinpack
If ! #Result
{
display You need to place more boards in your Resource Secure and hit play.
pause
GoTo MakePotashLoop
}
}
{
finditem %EmptyPitcher C_ , #backpackid
gosub ENs_FillPitchersFromWaterTrough
}
{
finditem %MortarPestle C_ , #backpackid
set #lobjectid #findid
If #findcnt < 2
gosub MakeMortarPestle
}
event macro 17
gosub waitforgump %cwin
if ! #result
{
Display Dbl Click a mortar and pestle in your backpack and hit play
Pause
}
gosub OffsetClick 25 190
gosub waitforgump %cwin
if ! #result
{
GoTo MakePotashLoop
}
Gosub OffSetClick 230 210 f
gosub waitforgump %cwin
if ! #result
{
GoTo MakePotashLoop
}
Gosub OffSetClick 281 452 f
gosub waitforgump %cwin
if ! #result
{
GoTo MakePotashLoop
}
gosub CheckPotash
return
;================Sub Move Resource==========================
Sub CheckPotash
finditem %Potash C_ , #backpackid
if #findstack >= 500
{
set %quantityinpack 500 - #findstack
gosub Move_Resource_To_Container %Potash 1102 #BackpackID %ResourceSecure %quantityinpack
}
goto MakePotashLoop
return
;================Sub Move Resource==========================
Sub Move_Resource_To_Container
; Sub moves a stackable resource from one container to another
; Checks Item Color to insure proper identification (Required)
; Will return #False if there are not enough of the resource
; #True with a successful move
;----------------------------------------------------------
; SAMPLE CALL Line
; Gosub Move_Resource_To_Container ItemType ItemColor ContainerIDSource ContainerIDDestination AmountToMve
;----------------------------------------------------------
namespace push
namespace local NCS
Set !ResourceItemType %1
Set !ResourceColor %2
Set !ResourceSource %3
Set !ResourceDestination %4
Set !ResourceCountToMove %5
Set !ResourceCountToMoveCheck %5
Finditem !ResourceItemType C_ , !ResourceSource
Set #findindex 0
Set #FindCol N/A
Set !ResourceLocated No
while #findindex < #findcnt && No in !ResourceLocated
{
set #findindex #findindex + 1
If #FindCol = !ResourceColor && #FindStack < !ResourceCountToMove && #FindCnt > #findindex
{
exevent drag #FindID #FindStack
Wait 15
exevent dropc !ResourceDestination
Wait 15
Set !ResourceCountToMove !ResourceCountToMove - #FindStack
Set #findindex 0
Finditem !ResourceItemType C_ , !ResourceSource
}
If #FindCol = !ResourceColor && #FindStack >= !ResourceCountToMove
{
exevent drag #FindID !ResourceCountToMove
Wait 15
exevent dropc !ResourceDestination
Wait 15
Set !ResourceLocated Yes
}
}
If #FindIndex = 0 || No in !ResourceLocated
{
IgnoreItem Reset
Namespace pop
Return #False
}
Finditem !ResourceItemType C_ , !ResourceDestination
Set #findindex 0
Set #FindCol N/A
Set !ResourceLocated No
while #findindex < #findcnt && No in !ResourceLocated
{
set #findindex #findindex + 1
If #FindCol = !ResourceColor && #FindStack >= !ResourceCountToMoveCheck
{
Namespace pop
IgnoreItem Reset
Return #True
}
}
Namespace pop
Return #False
;=================sub ENs_FillPitchers======================
sub ENs_FillPitchersFromWaterTrough ; %1= troughrange , defaults to 12 if nothing passed
If %waterTroughTypes = N/A
set %waterTroughTypes TEE_WEE_QEE_VEE
IF %emptypitcherTypes = N/A
set %emptypitcher WYF
If %0 <> 1
set %waterTroughRange 12
finditem %waterTroughTypes G_ , %waterTroughRange
If #Findcnt = 0
event exmsg #charid 3 0 ERROR No Water Trough Found
IF #findcnt > 0
{
set %WaterTroughId #findid
finditem %emptypitcher C_ , #backpackid
if #findcnt > 0
{
For #findindex 1 #findcnt
{
set #lobjectid #findid
event exmsg #charid 3 0 Empty pitchers found, filling! #findindex of #findcnt
event macro 17
target 5s
set #Ltargetkind 1
set #ltargetid %WaterTroughID
event macro 22
wait 20
}
}
}
return
;==================Sub Wait for Gump=========================
sub waitforgump
set %timeout #scnt + 10
while #contsize <> %1
{
wait 1
if #scnt > %timeout
{
return #false
}
}
wait %gumpwait
return #true
;==================Sub Wait for Target Cursor================
sub WaitForTargetCursor
set %timeout #scnt + 4
Repeat
wait %targetcursorwait
if #scnt > %timeout
return #false
Until #TARGCURS = 1
return #true
;=================Sub Offset Click===========================
sub OffsetClick
set %tempx %1 + #CONTPOSX
set %tempy %2 + #CONTPOSY
click %tempx %tempy f
return
-
this is your error (math)... you call the move_resource... sub with the quantity to move = %quantityinpack
you set %quantityinpack as
finditem %Potash C_ , #backpackid
if #findstack > 500
{
set %quantityinpack 500 - #findstack
So reading this if quantity in pack < 500 do nothing
if quantity in pack > 500 then move 500 - #stacksize = a negative number as we already detemined findstack > 500 .. so move a negative stack.. !!!!
Should be set %quantityinpack 500 as thats what you want to move right.
-
You have those "500 - #findstack" or "10 - #findstack", etc all over the script.
I don't suppose these are evaluating the way you intend them to.
Might want to review those as well...
-
Wow was I reading that wrong. I was looking at line 234
Set !ResourceCountToMove !ResourceCountToMove - #FindStack
so thought I needed the dash in there,didn't realize it was a minus. Thank you both!! :)
-
Okay I adjusted the CheckPotash sub to also quit after making the 500 so it is now:
;================Sub Check Potash==========================
Sub CheckPotash
finditem %Potash C_ , #backpackid
if #findstack < 500
goto MakePotashLoop
if #findstack >= 500
{
set %quantityinpack 500 #findstack
gosub Move_Resource_To_Container %Potash 1102 #BackpackID %ResourceSecure %quantityinpack
}
Halt
Lets say that the user wants to set it to 200 instead of 500. How can I set it so that the user can set the amount of potash to make 200 instead of the 500. I would like for them to be able to adjust that when they first choose to make potash instead of having to edit the checkpotash sub.
-
Okay I adjusted the CheckPotash sub to also quit after making the 500 so it is now:
;================Sub Check Potash==========================
Sub CheckPotash
finditem %Potash C_ , #backpackid
if #findstack < 500
goto MakePotashLoop
if #findstack >= 500
{
set %quantityinpack 500 #findstack
gosub Move_Resource_To_Container %Potash 1102 #BackpackID %ResourceSecure %quantityinpack
}
Halt
Lets say that the user wants to set it to 200 instead of 500. How can I set it so that the user can set the amount of potash to make 200 instead of the 500. I would like for them to be able to adjust that when they first choose to make potash instead of having to edit the checkpotash sub.
Well, there's a few ways to do this.
The easiest one (for you) would be to write a section on top of the script where users could change certain variables. Make sure to make it easy for people to see where to edit.
Something like this:
;======= user preferences =======
set %potashamount 500 ; change this value to suit your needs
;======= end user preferences =======
The user could just change it to whatever value he'd want, and the script would then use this variable instead of a fixed amount:
;================Sub Check Potash==========================
Sub CheckPotash
finditem %Potash C_ , #backpackid
if #findstack < %potashamount
goto MakePotashLoop
if #findstack >= %potashamount
{
set %quantityinpack %potashamount #findstack
gosub Move_Resource_To_Container %Potash 1102 #BackpackID %ResourceSecure %quantityinpack
}
Halt
-
Thanks that is a good way to work it if I can't get the menu to work. Thanks again for your help, I have a lot to learn and you are showing me some good stuff. BTW I love your termur lumberjack script. I use it a lot and it runs great! :)
-
set %quantityinpack 500 #findstack
The function of #findstack in the above statment is ?????
set Var Value
you have set Var Value Value ??
if you just want a comment then do
set %quantityinpack 500 ; #findstack ; = comment start
-
set %quantityinpack 500 #findstack
The function of #findstack in the above statment is ?????
set Var Value
you have set Var Value Value ??
if you just want a comment then do
set %quantityinpack 500 ; #findstack ; = comment start
lol, didn't even notice that one :S