Take the Tour | Site Map

It is currently Thu Mar 21, 2019 8:00 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Nov 19, 2018 9:25 pm 
Offline
Script Kiddie
Script Kiddie

Joined: 10/09/2018 15:17
Posts: 8
I am trying to combine 3 different macro files together with call command.
And it isn't working for some reason.
Inspire me please.
Individual macros work fine.
I read easyuo wiki call command, there must be something I am missing.

What happens is that however I change the macro, On second time I end up on the display yesno, it will go to some location I am not supposed to be and macro won't work properly.
for example, with current three macro below, the macro will end up on the top lines of move ore to horse macro and will just stop there after executing display ok choose your packhorse.

I know I am missing something about call command, inspire me. :)

This macro finds corner of 8 x 8 tile, and dig 4 tiles from one spot.
Then ask to keep digging or move to next macro, which moves ore from ground into packhorse
Code:
  1. gosub starting
  2.  
  3. sub starting
  4. {
  5.  event sysmessage click z to start
  6.  wait 20
  7.  gosub ToGrid
  8. }
  9. sub ToGrid
  10.  {
  11.   set %x N/A
  12.   set %x #CHARPOSX / 8
  13.   if #CHARPOSX > ( %x  * 8 )
  14.    {
  15.     event sysmessage X Not on the grid.
  16.     wait 10
  17.     gosub ToGrid
  18.    }
  19.   set %y N/A
  20.   set %y #CHARPOSY / 8
  21.   if #CHARPOSY > ( %y  * 8 )
  22.    {
  23.     event sysmessage Y Not on the grid.
  24.     wait 10
  25.     gosub ToGrid
  26.    }
  27.   else
  28.       event sysmessage On the spot.$
  29.       gosub DigTop
  30.  }
  31. sub DigTop
  32.  {
  33.   repeat   ;; dig top
  34.    {
  35.     event sysmessage digging top
  36.     key 8
  37.     wait 20
  38.     set %TopX  #CHARPOSX - 1
  39.     set %TopY  #CHARPOSY - 1
  40.     set #LTargetX %TopX
  41.     set #LTargetY %TopY
  42.     set #LTargetZ 0
  43.     event macro 22 0
  44.     wait 10
  45.     scanjournal 1
  46.     if no_metal in #journal
  47.      set %check 1
  48.    }
  49.   until %check = 1
  50.    event sysmessage Top Depleted.
  51.    set %check 0
  52.    gosub DigBot
  53.  }
  54. sub DigBot
  55.  {
  56.   repeat   ;; dig Bot
  57.    {
  58.     event sysmessage digging bot
  59.     key 8
  60.     wait 20
  61.     set %BotX  #CHARPOSX + 1
  62.     set %BotY  #CHARPOSY + 1
  63.     set #LTargetX %BotX
  64.     set #LTargetY %BotY
  65.     set #LTargetZ 0
  66.     event macro 22 0
  67.     wait 10
  68.     scanjournal 1
  69.     if no_metal in #journal
  70.      set %check 1
  71.    }
  72.    until %check = 1
  73.     event sysmessage Bot Depleted.
  74.     set %check 0
  75.     gosub DigLeft
  76.  }
  77. sub DigLeft
  78.  {
  79.   repeat   ;; dig Left
  80.    {
  81.     event sysmessage digging left
  82.     key 8
  83.     wait 20
  84.     set %LeftX #CHARPOSX - 1
  85.     set %LeftY #CHARPOSY + 1
  86.     set #LTargetX %LeftX
  87.     set #LTargetY %LeftY
  88.     set #LTargetZ 0
  89.     event macro 22 0
  90.     wait 10
  91.     scanjournal 1
  92.     if no_metal in #journal
  93.      set %check 1
  94.    }
  95.    until %check = 1
  96.     event sysmessage Left Depleted.
  97.     set %check 0
  98.     gosub DigRight
  99.   }
  100. sub DigRight
  101.  {
  102.   repeat   ; dig Right
  103.     {
  104.     event sysmessage digging Right
  105.     key 8
  106.     wait 20
  107.     set %RightX #CHARPOSX + 1
  108.     set %RightY #CHARPOSY - 1
  109.     set #LTargetX %RightX
  110.     set #LTargetY %RightY
  111.     set #LTargetZ 0
  112.     event macro 22 0
  113.     wait 10
  114.     scanjournal 1
  115.     if no_metal in #journal
  116.      set %check 1
  117.    }
  118.    until %check = 1
  119.     event sysmessage Right Depleted.
  120.     set %check 0
  121.     event sysmessage completed.
  122.     gosub WhatNext
  123.  }
  124. sub WhatNext
  125.  {
  126.   display yesno What to do next? $ Yes : continue to mine $ No : Move ores to packhorse $
  127.  
  128.   if #dispres = yes
  129.    {
  130.    gosub starting
  131.    }
  132.    if #dispres = no
  133.    {
  134.      CALL OreToPackhorse1.txt
  135.    }
  136.  
  137.  
  138.   }
  139.  
  140.  


This macro moves Ore to packhorse, then ask to continue to look for ores on the ground or move to next macro, which finds forge and smelt ore.

Code:
  1. set %OreType DWJ_
  2. display ok choose your packhorse
  3. loop:
  4.  goto loop:
  5. set %packhorse #ltargetid
  6. set #lobjectid %packhorse
  7. wait 10
  8.  gosub SearchOre
  9.  
  10.  
  11. gosub SearchOre
  12. sub SearchOre
  13. {
  14.  
  15.   findloop:
  16.    finditem %OreType G_2
  17.    if #findcnt = 0
  18.     {
  19.     msg looking$
  20.     wait 20
  21.     goto findloop:
  22.     }
  23.    else
  24.     msg found$
  25.     gosub MoveOre
  26. }
  27.  
  28. sub MoveOre
  29.  {
  30.    {
  31.          wait 20
  32.    wait 10
  33.    exevent dropc %packhorse
  34.    wait 10
  35.    }
  36.   gosub WhatNext
  37.  }
  38. sub WhatNext
  39.  {
  40.   display yesno What to do next? $ Yes : Move ores to packhorse $ No :  Find a forge and smelt $
  41.    if #dispres = yes
  42.     {
  43.      gosub SearchOre
  44.     }
  45.    if #dispres = no
  46.     {
  47.      CALL ForgeSmelt.txt
  48.     }
  49.  
  50.   }
  51.  


And finally this macro look for forge and get ore from packhorse and put it down on the ground, and smelt them.
And ask to go back mining or quit the macro.

Code:
  1. display ok choose your packhorse
  2. loop:
  3.  goto loop:
  4. set %packhorse #ltargetid
  5. set #lobjectid %packhorse
  6.  
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8. set %OreType DWJ_
  9.  gosub findforge
  10. gosub findforge
  11. sub findforge
  12.  {
  13.   set %thisforge N/A
  14.   set %forge IVJ_JBG_JJ
  15.   finditem %forge G_2
  16.   set %thisforge #findid
  17.   wait 15
  18.   msg found a forge it is %thisforge $
  19.   gosub GetOre
  20.  }
  21. sub GetOre
  22.  {
  23.    event macro 17 0
  24.    wait 15
  25.    set %pack #contid
  26.    loop:
  27.     finditem %OreType C_ , %pack
  28.     if #findcnt > 0
  29.      {
  30.         wait 10
  31.         wait 10
  32.         finditem %OreType G_0
  33.         wait 10
  34.         set #lobjectid #findid
  35.         event macro 17 0
  36.         wait 10
  37.         set #ltargetid %thisforge
  38.         event macro 22 0
  39.         wait 10
  40.         goto loop
  41.      }
  42.  
  43.  msg complete $
  44.  gosub WhatNext
  45.  }
  46. sub WhatNext
  47.  {
  48.   display yesno What to do next? $ Yes : continue to mine $ No : finish
  49.    if #dispres = yes
  50.     {
  51.      call 4CornerMining.txt
  52.     }
  53.    if #dispres = no
  54.     {
  55.     halt
  56.     }
  57.  
  58.   }


Top
  Profile 
PostPosted: Mon Nov 19, 2018 9:32 pm 
Offline
Script Kiddie
Script Kiddie

Joined: 10/09/2018 15:17
Posts: 8
After writing all these in this forum I found the answer myself again.
I am using multiple clients(3) and what I didn't do is that I didn't arrange the 3 macros all into one client I am mining.
After I corrected it, it works like charm.


Top
  Profile 
PostPosted: Mon Nov 19, 2018 10:44 pm 
Offline
Administrator
Administrator
User avatar

Joined: 08/12/2003 07:28
Posts: 19007
Location: Switzerland

1st: Quote-tags are NOT equal to code-Tags. I changed that for you.
2nd: Your sub-Structure is wrong. Please read on how to properly exit a sub and how they should be used.
Example:
Code:
  1. gosub starting
  2.  ; Where is your stop-condition of the maincode?? your code falls trough and will looparound!
  3.  
  4. sub starting ; OK... you start a sub. Unnecessary, as you just could continue as maincode without any sub-structure at all. It is like "goto next line". Duh. useless as without the command i would have gone to this line anyway...
  5. {
  6. wait 20
  7. gosub ToGrid ; Why you gosub to code just next in line? No need to gosub or make a sub.
  8. } ; Where is your return???? Sub without return --> EUO will ignore gosub-commands after a certain gosub-depth!
  9. sub ToGrid
  10. {
  11. set %x N/A
  12. set %x #CHARPOSX / 8
  13. if #CHARPOSX > ( %x * 8 )
  14. {
  15. event sysmessage X Not on the grid.
  16. wait 10
  17. gosub ToGrid ; Eh... Recursive calling of subs? Boy, you better knwo what you are doing! In your case a simple loop would work the same and would be CORRECT.
  18. }
  19. set %y N/A
  20. set %y #CHARPOSY / 8
  21. if #CHARPOSY > ( %y * 8 )
  22. {
  23. event sysmessage Y Not on the grid.
  24. wait 10
  25. gosub ToGrid ; You just love your recursions, dont you? Recipe for fail due to maximum gosub-depth reached after a certain time running...
  26. }
  27. event sysmessage On the spot.$
  28. gosub DigTop ; Again: Why oh why you gosub if you could just go on without any gosubbing at all?
  29. } ; Again, No return. Sub is faulty.
  30. sub DigTop
  31. {
  32. repeat ;; dig top
  33. {
  34. event sysmessage digging top
  35. key 8
  36. ...
  37. ...


Attachments:
FB_IMG_1542743977775.jpg
FB_IMG_1542743977775.jpg [ 34.07 KiB | Viewed 1284 times ]

_________________
EUO Member and postwhore since: 19th Dezember, 2002; Loosing on freeshard Alexandria since: 5th January, 2005
Searches cure for cancer since: 17th November, 2003 on GRID.org & Worldcommunitygrid.org
Made scripts for Project 'Programmers for Alexandria' worth 50$
Image
Quote "mmorning": Where would theses boards be if Orn didn't miss all the sarcasm. Man its great having him here :)
Quote "author-unknown": Good idea. I gotta start doing that too. You're a trendsetter Orn. :)
Quote "dreyfus": #true is always #true
Top
  ProfileShow poster's scripts in the public script library 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: Google [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Hosted by CalWeb Internet Services, Inc.