Openkore.com
http://forums.openkore.com/

Can anyone help me with a couple series of Macros?
http://forums.openkore.com/viewtopic.php?f=32&t=212223
Page 1 of 3

Author:  ytbro00 [ 16 Aug 2017, 04:51 ]
Post subject:  Can anyone help me with a couple series of Macros?

So I'm trying to have my bots autodeal my merchant as soon as they're done auto selling & auto buying. My actual macro itself partially works. I'd just like to tweak on the trigger and auto adding. So here's a modified sample of what I'm trying to tweak around on.

1. I did not put weight trigger because I have my bots set to go back for auto buying and selling once they run out of potions and fly wings. Which is why I'm trying to get the macro to trigger as soon as I get to town.

2. Trying to get checkZeny to work. I'm able remove that line and simply do add z "amount," but is there a way to leave at least 50k - 100k on my farming bots so that they have enough money to auto-buy what they need?

3. I've been able to successfully add numerous amounts of items. Can anyone clarify if it's possible to just keep adding the same item like composite bow, wooden mail, knife until there are none left to trade without having to add multiple lines of the do deal add @inventory?

I have left a couple notes after "#" next to the code.


Code:
automacro moveToMaster { #How can I trigger the macro to run as soon as my bot goes back to town (dies / uses butterfly wing)
   location #where my merchant is sitting
   call {
      do autosell
      do autobuy
      do conf lockMap
      do conf lockMap_x
      do conf lockMap_y
      do move payon
   }
   run-once 1
}

automacro dealToMaster {
   location #where my merchant is sitting
   call {
      do deal @player
      pause 3
      macro checkZeny { #not sure if this is working correctly
      switch ($.zeny) {
      case (> 200000) {
      do deal add z 100000 #any way to deal all zeny and just leave at least 100k on my farmer?
      pause 1
      do deal add @inventory(Hood [1]) #How can I add hood until I have none left without repeating the code?
      pause 1
      do deal
     pause 1
     do deal
   }
   run-once 1
}

automacro moveToFild { #where my bots are farming
   console /Deal Complete/i
   call {
      do conf lockMap
      do conf lockMap_x none
      do conf lockMap_y none
     do move
      do reload mac
   }
}


Any help is appreciated. Thanks.

Author:  hakore [ 16 Aug 2017, 08:28 ]
Post subject:  Re: Can anyone help me with a couple series of Macros?

location for moveToMaster should be the town name only.

If you already enabled sellAuto and buyAuto in config, remove the do autosell and do autobuy in you macro.

If you are already setting lockMap/_x/_y to near the location of the master, you don't have to add a do move, lockMap AI will move on it's own

Also, add a release in your macro as most of them are run-once

Try to work on this (not tested):
Code:
automacro dealToMaster {
   location #where my merchant is sitting
   call {
      do deal @player(#your name)
      pause 3
       if ($.zeny >= 200000) {
         do deal add z @eval($.zeny - 100000)
      }
      pause 1
      $hoods = @Inventory(Hood [1])
      while ($hoods != -1 || $hoods != "") as loop
         do deal add [$hoods]
         pause 1
      end loop
      pause 1
      do deal
      pause 1
      do deal
   }
   run-once 1
}

Author:  ytbro00 [ 17 Aug 2017, 01:56 ]
Post subject:  Re: Can anyone help me with a couple series of Macros?

hakore wrote:
location for moveToMaster should be the town name only.

If you already enabled sellAuto and buyAuto in config, remove the do autosell and do autobuy in you macro.

If you are already setting lockMap/_x/_y to near the location of the master, you don't have to add a do move, lockMap AI will move on it's own

Also, add a release in your macro as most of them are run-once

Try to work on this (not tested):
Code:
automacro dealToMaster {
   location #where my merchant is sitting
   call {
      do deal @player(#your name)
      pause 3
       if ($.zeny >= 200000) {
         do deal add z @eval($.zeny - 100000)
      }
      pause 1
      $hoods = @Inventory(Hood [1])
      while ($hoods != -1 || $hoods != "") as loop
         do deal add [$hoods]
         pause 1
      end loop
      pause 1
      do deal
      pause 1
      do deal
   }
   run-once 1
}



Thanks, Hakore. Got it to work but somehow after the zeny where the equipment adding are. it gives me an error. Removing those lines I'm able to get the zeny through no problem.


Image

Author:  hakore [ 17 Aug 2017, 02:21 ]
Post subject:  Re: Can anyone help me with a couple series of Macros?

Lol, I was assuming the syntax was more forgiving... Try this replacement:
Code:
   $hoods = @Inventory(Hood [1])
   while ($hoods != -1 || $hoods != "") as loop
      $hood = [$hoods]
      do deal add $hood
      pause 1
   end loop

Author:  romcel11 [ 17 Aug 2017, 02:49 ]
Post subject:  Re: Can anyone help me with a couple series of Macros?

hakore wrote:
Lol, I was assuming the syntax was more forgiving... Try this replacement:
Code:
   $hoods = @Inventory(Hood [1])
   while ($hoods != -1 || $hoods != "") as loop
      $hood = [$hoods]
      do deal add $hood
      pause 1
   end loop


Am I correct to assume,
1) that in this code $hoods is a variable?
2) that $hood is being checked by the while loop if there are remaining hoods in inventory?
3) that $hood is also used to refer to that existing item?

Follow up question, is there a/any way to check for multiple (or a list of) items?

Thanks in advance!

Author:  ytbro00 [ 17 Aug 2017, 03:08 ]
Post subject:  Re: Can anyone help me with a couple series of Macros?

hakore wrote:
Lol, I was assuming the syntax was more forgiving... Try this replacement:
Code:
   $hoods = @Inventory(Hood [1])
   while ($hoods != -1 || $hoods != "") as loop
      $hood = [$hoods]
      do deal add $hood
      pause 1
   end loop


Worked after I removed "||" and did this. It added the items I wanted it to, but now it keeps looping and not executing "end loop" Used mufflers for testing.

Code:
automacro dealToMaster {
   location #where my merchant is sitting
   call {
      do deal @player(#myname)
      pause 3
       if ($.zeny >= 400000) {
                do deal add z @eval($.zeny - 100000)
      }
      pause 1
      $mufflers = @Inventory(Muffler [1])
      while ($mufflers != -1 ) as loop
            do deal add $mufflers
            pause 1
      end loop
      pause 1
      do deal
      pause 1
      do deal
   }
   run-once 1
}


Image

Author:  hakore [ 17 Aug 2017, 03:18 ]
Post subject:  Re: Can anyone help me with a couple series of Macros?

Lol, you removed the [$...] part. That's the key to the loop. Try it again unchanged.

Code:
   $list = @Inventory(Muffler [1])
   log This is the list of indexes for Mufflers (\$list): $list
   $i = 0
   while ($list != -1 && $list != "") as loop
      $item = [$list]
      log We are now adding item number (\$item):  $item
      log These are the remaining items on the list (\$list): $list
      do deal add $item
      pause 1
      $i++
      if ($i = 10) {
         $list = ""
      }
   end loop


Edit: || should be &&

Author:  ytbro00 [ 17 Aug 2017, 03:28 ]
Post subject:  Re: Can anyone help me with a couple series of Macros?

Ok, did so without trying to fix anything in your code at all. It's working and adding it, but right after, it disconnects. Image below the console and error message.

EDIT: Actually just saw the comment about the || being &&. The image posted below is the one with ||. Just tried now with && successfully puts in all mufflers but right after it puts in the last one it gives the message "[macro] dealToMaster.call error: error in 9: syntax error in if statement"

Image

Author:  hakore [ 17 Aug 2017, 04:10 ]
Post subject:  Re: Can anyone help me with a couple series of Macros?

Well, maybe you can just remove the "if" there. And the $i. It's just an idea.

I think it wouldn't hurt except that it will attempt to loop through everything and add items to the deal even if the deal is already full.

Author:  ytbro00 [ 17 Aug 2017, 08:00 ]
Post subject:  Re: Can anyone help me with a couple series of Macros?

No luck. Even if I remove "if" and "$i". It still gives me [macro] dealToMaster.call error: error in 5: syntax error in if statement

EDIT:

Tried it again. The if condition only works and successfully completes the macro if I input a number less than or equal to the mufflers I have. The number entered on $i is the number of mufflers it places on trade window. In this case, I have 5. Anything over than 5 returns the syntax error. Even If I remove it. So in this case it would still get stuck eventually if it doesn't get the amount specified before trading.

Code:
$list = @Inventory(Muffler [1])
      log This is the list of indexes for Mufflers (\$list): $list
      $i = 0
      while ($list != -1 && $list != "") as loop
      $item = [$list]
      log We are now adding item number (\$item):  $item
      log These are the remaining items on the list (\$list): $list
      do deal add $item
      pause 1
      $i++
      if ($i = 5) { # Doesn't work when I enter 6 or up. The number I enter here is the number of mufflers it places on trade window.
      $list = ""
      }
      end loop
      pause 1
       do deal
      pause 1
     do deal
   }
   run-once 1
}


Page 1 of 3 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/