Author Topic: Error with Menu  (Read 10430 times)

0 Members and 1 Guest are viewing this topic.

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3019
  • Activity:
    3.2%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Error with Menu
« on: February 22, 2013, 05:19:07 PM »
0
Before I added the menu, the sub MakePotash looped perfectly and kept making potash until the resource bag ran out of boards. After adding the menu, when you choose potash, it goes through the loop once and sits idle. What did I do wrong? I am stumped on this. The other crafting subs have not been added yet, working on one sub at a time.

Code: [Select]
;=========================================
Start:
Gosub Setup
;=========================================
;--------- EasyUO Menu Designer Code Begin ---------
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 %item Potash
if #menures = 2
   set %item BlkPwdr
if #menures = 3
   set %item LtPwdrChg
if #menures = 4
   set %item HvyPwdrChg
if #menures = 5
   set %item LtGrpSht
if #menures = 6
   set %item LtCanBall
if #menures = 7
   set %item HvyGrpSht
if #menures = 8
   set %item HvyCanBall
choosesitem %item
return
if %item = Potash
      {
      gosub MakePotash
      }
   if %Item = BlkPwdr
      {
      gosub MakeBlackPowder
      }
if %item = LtPwdrChg
      {
      gosub LightPowderCharge
      }
if %item = HvyPwdrChg
      {
      gosub HeavyPowderCharge
      }
if %Item = LtGrpSht
      {
      gosub LightGrapeShot
      }
if %Item = LtCanBall
      {
      gosub LightCannonBall
      }
if %Item = HvyGrpSht
      {
      gosub HeavyGrapeShot
      }
if %Item = HvyCanBall
      {
      gosub HeavyCannonBall
      }
until #charghost = yes
while #charGhost = YES
  wait 0
  return

;===================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 %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 Make Potash===========================
Sub MakePotash
    Display You must be next to a water trough and have a water pitcher in your backpack.
    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
              }
              return

;========================Sub Make TinkerKit==================
Sub MakeTinkerKit
    MakeKitLoop:
    finditem %Ingots C_ , #backpackid
         if #findstack < 10
         {
         set %quantityinpack 10 - #findstack
         Gosub Move_Resource_To_Container %Ingots 0 %ResourceSecure #BackpackID %quantityinpack
         If ! #Result
            {
            display You need to place more ingots in your Resource Secure and hit play.
            pause
            GoTo MakeKitLoop
            }
         }
         finditem %TinkerTools C_ , #backpackid
         set #lobjectid #findid
         event macro 17
              gosub waitforgump %cwin
              if ! #result
              {
              Display Dbl Click a tinker kit in your backpack and hit play
              Pause
              }
              Gosub OffSetClick 30 130
              gosub waitforgump %cwin
              if ! #result
              {
              GoTo MakeKitLoop
              }
              Gosub OffSetClick 230 130 f
              gosub waitforgump %cwin
              if ! #result
              {
              GoTo MakeKitLoop
              }
              Gosub OffSetClick 230 130 f
              gosub waitforgump %cwin
              if ! #result
              {
              GoTo MakeKitLoop
              }
         Return
         
;======================Sub Make MortarPestle======================
Sub MakeMortarPestle
    MakeMortarPestleLoop:
    finditem %Ingots C_ , #backpackid
         if #findstack < 10
         {
         set %quantityinpack 10 - #findstack
         Gosub Move_Resource_To_Container %Ingots 0 %ResourceSecure #BackpackID %quantityinpack
         If ! #Result
            {
            display You need to place more ingots in your Resource Secure and hit play.
            pause
            GoTo MakeMortarPestleLoop
            }
         }
         finditem %TinkerTools C_ , #backpackid
         set #lobjectid #findid
         If #findcnt < 2
         gosub MakeTinkerKit
         event macro 17
              gosub waitforgump %cwin
              if ! #result
              {
              Display Dbl Click a tinker tool in your backpack and hit play
              Pause
              }
              gosub OffsetClick 27 129
              gosub waitforgump %cwin
              if ! #result
              {
              GoTo MakeKitLoop
              }
              Gosub OffSetClick 232 89 f
              gosub waitforgump %cwin
              if ! #result
              {
              GoTo MakeKitLoop
              }
              Gosub OffSetClick 281 451 f
              gosub waitforgump %cwin
              if ! #result
              {
              GoTo MakeKitLoop
              }
              Gosub OffSetClick 281 451 f
              gosub waitforgump %cwin
              if ! #result
              {
              GoTo MakeKitLoop
              }
         Return
         
;================== Wait for gump ======================
sub waitforgump
set %timeout #scnt + 10
while #contsize <> %1
      {
      wait 1
      if #scnt > %timeout
         {
          return #false
         }
      }
wait %gumpwait
return #true
;================== Wait for Target Cursor ================
sub WaitForTargetCursor
set %timeout #scnt + 4
Repeat
      wait %targetcursorwait
      if #scnt > %timeout
         return #false
Until #TARGCURS = 1
return #true

;==========================================================
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 OffsetClick
  set %tempx %1 + #CONTPOSX
  set %tempy %2 + #CONTPOSY
  click %tempx %tempy f
return

;============================================
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

Offline Neo

  • Prime Program
  • Elite
  • *
  • *
  • Posts: 821
  • Activity:
    0%
  • Reputation Power: 13
  • Neo barely matters.Neo barely matters.
  • Respect: +155
  • Referrals: 3
    • View Profile
Re: Error with Menu
« Reply #1 on: February 22, 2013, 11:37:56 PM »
0
You have to be careful with the script flow. You should organize your subs better.

Regarding the flow of the script as it is right now:

In line 3
Code: [Select]
Gosub setupThis will take you to line 112 which is the setup sub

Then it will start executing each line in a sequence inside that sub.

When it gets to line 137
Code: [Select]
gosub mainmenuIt will jump back to line 6 which is the MainMenu sub. This will start drawing your menu, and will wait for the user input.

Ok, now let's say I chose Potash from the menu and hit start. The following will happen:

The %item var will be set to Potash

Then, on line 72
Code: [Select]
choosesitem %itemWhat's this supposed to do? I don't know what this line means! :(

But okay, getting past that, on line 73 you will get a 'return'

This is going to take you back to where this sub was first called.

So you will be back on line 137, and the script is going to find another return on line 139 which will bring you back to line 4. Lines 4 and 5 are comments, so we'll be on line

Since line 6 is the entry point to the MainMenu sub, it will skip that whole code sub and jump again to line 74

Ok, so now we have
Code: [Select]
if %item = Potash
    gosub MakePotash
so this will take you to the MakePotash sub

It's really confusing the way this is written, and it can lead to simple mistakes being overlooked. I would suggest you try and rewrite it with a little bit more organization, that would make things a lot simpler for you.

Well, anyways, that's just me babbling.


Now to your problem specifically.

I don't have a character to try that out with, but from reading the code it seems that this is where it's going wrong:

On line 106, you have
Code: [Select]
until #charghost = yesTo use "until something", you should have written a repeat in there somewhere to actually repeat the code that's between those lines. Something like this:

Code: [Select]
repeat
;code
;code
;code
until #charghost = yes
I suppose you meant to have it repeat the code starting from "if %item = Potash" until that part, so you should add the "repeat" line just above line 74. The code would look like this, for that part:

Code: [Select]
repeat
if %item = Potash
      {
      gosub MakePotash
      }
   if %Item = BlkPwdr
      {
      gosub MakeBlackPowder
      }
if %item = LtPwdrChg
      {
      gosub LightPowderCharge
      }
if %item = HvyPwdrChg
      {
      gosub HeavyPowderCharge
      }
if %Item = LtGrpSht
      {
      gosub LightGrapeShot
      }
if %Item = LtCanBall
      {
      gosub LightCannonBall
      }
if %Item = HvyGrpSht
      {
      gosub HeavyGrapeShot
      }
if %Item = HvyCanBall
      {
      gosub HeavyCannonBall
      }
until #charghost = yes
I hope this is somewhat clear, and able to help you out a little bit.

Let me know if you have questions, or if this doesn't solve your problem specifically.

[]s
Never refuse an invitation.
Never resist the unfamiliar.
Never fail to be polite.
And never outstay your welcome.

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3019
  • Activity:
    3.2%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: Error with Menu
« Reply #2 on: February 23, 2013, 03:40:39 AM »
0
I am very very new to trying to write scripts and I might be a little overambitious but that is the way I am sometimes. I appreciate your help and will go back through it and see if I can make it more clear. I have read the tutorials but they don't really cover crafting or some of the things I am trying to do so I am trying to look at other scripts and learn from things that they do. One thing that I have noticed is that people write their scripts very differently and sometimes their script language/commands varies greatly from other scripts of theirs.

I am sure that I will come up with many questions while I go through this script so I greatly appreciate your help and advice.  :)

If anyone ever wanted to take a scripting protege and teach them, I am available!!

Offline Neo

  • Prime Program
  • Elite
  • *
  • *
  • Posts: 821
  • Activity:
    0%
  • Reputation Power: 13
  • Neo barely matters.Neo barely matters.
  • Respect: +155
  • Referrals: 3
    • View Profile
Re: Error with Menu
« Reply #3 on: February 23, 2013, 07:42:21 AM »
0
I am very very new to trying to write scripts and I might be a little overambitious but that is the way I am sometimes. I appreciate your help and will go back through it and see if I can make it more clear. I have read the tutorials but they don't really cover crafting or some of the things I am trying to do so I am trying to look at other scripts and learn from things that they do. One thing that I have noticed is that people write their scripts very differently and sometimes their script language/commands varies greatly from other scripts of theirs.

I am sure that I will come up with many questions while I go through this script so I greatly appreciate your help and advice.  :)

If anyone ever wanted to take a scripting protege and teach them, I am available!!
Don't take me wrong... I didn't say all those things to criticize or anything like that... I just meant to point you in the right direction.

I'd be happy to help you out, especially since you seem really motivated.

I am known to disappear for like, 2 years, and come back though, so be warned! :D

Anyways, let us know whatever questions you may have, we'll do our best to try and help out!

[]s
Never refuse an invitation.
Never resist the unfamiliar.
Never fail to be polite.
And never outstay your welcome.

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3019
  • Activity:
    3.2%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: Error with Menu
« Reply #4 on: February 23, 2013, 09:25:54 AM »
0
You have to be careful with the script flow. You should organize your subs better.

Regarding the flow of the script as it is right now:

In line 3
Code: [Select]
Gosub setupThis will take you to line 112 which is the setup sub

Then it will start executing each line in a sequence inside that sub.

When it gets to line 137
Code: [Select]
gosub mainmenuIt will jump back to line 6 which is the MainMenu sub. This will start drawing your menu, and will wait for the user input. I am changing the order, trying to put it in more of a flow beginning to end. I am guessing that maybe when is coded more in order, the script runs more quickly and smoothly? If nothing else, it makes it easier for others.

Ok, now let's say I chose Potash from the menu and hit start. The following will happen:

The %item var will be set to Potash

Then, on line 72
Code: [Select]
choosesitem %itemWhat's this supposed to do? I don't know what this line means! :( To me it makes sense but maybe not in a scripting sense I guess. I might be misunderstanding EUO coding as well. I take it that there is a lot of liberty in naming things when you code though not all may be understandable to others. I am making items, I did not really know what to call it other than
Code: [Select]
%item. The scripts that I was looking at that used menus, were skill gain scripts and they had used
Code: [Select]
%skill. Most crafting scripts are for one skill or another like just blacksmithing. I don't have anything that I could find to compare to the script I am making due to it making things using different crafting skills. I am wanting the script to go to the MakePotash sub. So in my thinking, it is choosing to make potash and starts that sub. How can I fix this so it makes more sense to others and maybe work more smoothly? [/color]

But okay, getting past that, on line 73 you will get a 'return'

This is going to take you back to where this sub was first called.

So you will be back on line 137, and the script is going to find another return on line 139 which will bring you back to line 4. Lines 4 and 5 are comments, so we'll be on line

Since line 6 is the entry point to the MainMenu sub, it will skip that whole code sub and jump again to line 74 OKay, I will remove it. Returns end what you are doing and then send it back to the beginning of that sub, kind of like a repeat?

Ok, so now we have
Code: [Select]
if %item = Potash
    gosub MakePotash
so this will take you to the MakePotash sub

It's really confusing the way this is written, and it can lead to simple mistakes being overlooked. I would suggest you try and rewrite it with a little bit more organization, that would make things a lot simpler for you.

Well, anyways, that's just me babbling. My goal for this script is to be able to make all of the High Seas Munitions for myself and maybe a vendor. They are tedious and time consuming to make ATK so II had decided to make a couple of scripts for it. While working on the one for Potash, which was running fairly well, I decided it would be better and more fun for me to learn coding if I made one to do them all instead of separate scripts. This led to things getting jumbled and cluttered I believe because I needed things to be done in each crafting sub instead of having their own subs such as displaying that you need to be next to a water trough and what not. I am not the best at organization with in my work and home so my coding shows that lol. What can I do to clean it up and make it better?


Now to your problem specifically.

I don't have a character to try that out with, but from reading the code it seems that this is where it's going wrong:

On line 106, you have
Code: [Select]
until #charghost = yesTo use "until something", you should have written a repeat in there somewhere to actually repeat the code that's between those lines. Something like this:

Code: [Select]
repeat
;code
;code
;code
until #charghost = yes
I suppose you meant to have it repeat the code starting from "if %item = Potash" until that part, so you should add the "repeat" line just above line 74. The code would look like this, for that part:

Code: [Select]
repeat
if %item = Potash
      {
      gosub MakePotash
      }
   if %Item = BlkPwdr
      {
      gosub MakeBlackPowder
      }
if %item = LtPwdrChg
      {
      gosub LightPowderCharge
      }
if %item = HvyPwdrChg
      {
      gosub HeavyPowderCharge
      }
if %Item = LtGrpSht
      {
      gosub LightGrapeShot
      }
if %Item = LtCanBall
      {
      gosub LightCannonBall
      }
if %Item = HvyGrpSht
      {
      gosub HeavyGrapeShot
      }
if %Item = HvyCanBall
      {
      gosub HeavyCannonBall
      }
until #charghost = yes
I hope this is somewhat clear, and able to help you out a little bit. I think this helps me, gonna mess around with it and see what happens.

Let me know if you have questions, or if this doesn't solve your problem specifically.

[]s


I am very very new to trying to write scripts and I might be a little overambitious but that is the way I am sometimes. I appreciate your help and will go back through it and see if I can make it more clear. I have read the tutorials but they don't really cover crafting or some of the things I am trying to do so I am trying to look at other scripts and learn from things that they do. One thing that I have noticed is that people write their scripts very differently and sometimes their script language/commands varies greatly from other scripts of theirs.

I am sure that I will come up with many questions while I go through this script so I greatly appreciate your help and advice.  :)

If anyone ever wanted to take a scripting protege and teach them, I am available!!
Don't take me wrong... I didn't say all those things to criticize or anything like that... I just meant to point you in the right direction.

I'd be happy to help you out, especially since you seem really motivated.

I am known to disappear for like, 2 years, and come back though, so be warned! :D

Anyways, let us know whatever questions you may have, we'll do our best to try and help out!

[]s

I know you weren't criticizing and I appreciate your help. There are so many ideas that I have for scripts that I cannot wait to have a better understanding of it all.  :)

Offline Tidus

  • Lazy
  • Administrator
  • *
  • *
  • Posts: 1291
  • Activity:
    0%
  • Reputation Power: 15
  • Tidus is working their way up.Tidus is working their way up.Tidus is working their way up.
  • Gender: Male
  • Mind Blown
  • Respect: +151
  • Referrals: 2
    • View Profile
    • Ultimate Apparel
Re: Error with Menu
« Reply #5 on: February 23, 2013, 01:33:54 PM »
0
For later when you start using the other combos you have a problem... some are written as %Item and some %item.. you have two different variables there when you are only wanting one.  I didn't look at it with much detail because of the comments of how it is organized. I would reorganize it then resubmit it to be looked at.
For those who have fought for it, freedom has a taste the protected will never know ~ Anonymous, Vietnam, 1968

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3019
  • Activity:
    3.2%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: Error with Menu
« Reply #6 on: February 23, 2013, 02:35:45 PM »
0
Okay I have reorganized it and I changed
Code: [Select]
%item to
Code: [Select]
%craftable for 2 reasons. Neo was unsure about what it meant where it was used, and the move resources also used a
Code: [Select]
%item. I am guessing that the script could get confused with that as well. I have not added the tool crafting subs back in yet and will leave them out until closer to the end so it will be less code to look at.
Code: [Select]
;=========================================
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 %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
      }

;===================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

;===================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
              }

              GoTo MakePotashLoop

;================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

« Last Edit: February 23, 2013, 02:37:21 PM by Crisis »

Offline Tidus

  • Lazy
  • Administrator
  • *
  • *
  • Posts: 1291
  • Activity:
    0%
  • Reputation Power: 15
  • Tidus is working their way up.Tidus is working their way up.Tidus is working their way up.
  • Gender: Male
  • Mind Blown
  • Respect: +151
  • Referrals: 2
    • View Profile
    • Ultimate Apparel
Re: Error with Menu
« Reply #7 on: February 23, 2013, 02:41:59 PM »
0
Remember you need returns on any sub.  I noticed you are missing returns on some subs.
For those who have fought for it, freedom has a taste the protected will never know ~ Anonymous, Vietnam, 1968

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3019
  • Activity:
    3.2%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: Error with Menu
« Reply #8 on: February 23, 2013, 03:32:39 PM »
0
I added in the return to the end of the subs with it missing. I have it looping nicely and now I am trying to get it to do a couple of other things. Right now I am trying to get it to move stacks of 500 potash into my secure container. I have looked over Polonius' move resource sub and believe that I have it set up correctly but obviously I missed something because it keeps crafting regardless of the amount of potash in the backpack. The loop command is after it supposedly checks the potash. I am going to include the move resources sub and my makepotash sub instead of the entire script. Once it moves the stack of 500 I want it to halt but I have not put in that code yet because I want it to move the stack of 500 first. Using TM's FindInfo script, I found the color of potash to be 1102 which is what the script calls for to move resources.

Polonius' Move Resource Sub
Code: [Select]
;================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

MakePotash Sub
Code: [Select]
;===================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
              }
              finditem #Potash C_ , #backpackid
              if #findstack >= 500
              {
              set %quantityinpack 500 - #findstack
              Gosub Move_Resource_To_Container %Potash 1102 %ResourceSecure #BackpackID %quantityinpack
              }
              goto MakePotashLoop
              return

Offline Neo

  • Prime Program
  • Elite
  • *
  • *
  • Posts: 821
  • Activity:
    0%
  • Reputation Power: 13
  • Neo barely matters.Neo barely matters.
  • Respect: +155
  • Referrals: 3
    • View Profile
Re: Error with Menu
« Reply #9 on: February 23, 2013, 04:46:56 PM »
0
What I actually meant was I don't know what this line means:

choosesitem %craftable

Specifically the "choosesitem" thingy...

What's that supposed to do? I don't think there's such a command on EUO
Never refuse an invitation.
Never resist the unfamiliar.
Never fail to be polite.
And never outstay your welcome.

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3019
  • Activity:
    3.2%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Re: Error with Menu
« Reply #10 on: February 23, 2013, 05:26:20 PM »
0
What I actually meant was I don't know what this line means:

choosesitem %craftable

Specifically the "choosesitem" thingy...

What's that supposed to do? I don't think there's such a command on EUO

I was under the impression that when you chose from the drop down, that told the script what your choice was. I have no clue so I am going to try the script with it commented out and see what happens.

After editing it out:
It must be nonsense because no issues with it commented out.

Tags: