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