Can anyone help me with a couple series of Macros?

All about the macro plugin can be found in this forum. This forum is intended for the macro plugin only.

Moderator: Moderators

Message
Author
hakore
Super Moderators
Super Moderators
Posts: 214
Joined: 16 May 2008, 08:28
Noob?: No
Contact:

Re: Can anyone help me with a couple series of Macros?

#11 Post by hakore »

Try this:

Code: Select all

while ("$list" != "-1" && "$list" != "") as loop
Whatever...

ytbro00
Noob
Noob
Posts: 14
Joined: 01 Aug 2017, 16:44
Noob?: No

Re: Can anyone help me with a couple series of Macros?

#12 Post by ytbro00 »

Awesome! It works. Thanks a lot, hakore. Tested it a bit, works good still have some minor bugs though. Code below to help other players as well.

There are 2 more questions that I'd like to ask regarding this. Both a little connected to each other
  • 1. While testing I came across that the slave would get stuck if it fails to deal the master what would seem like it's trying to proceed with trading and adding items even if trade window is not up. Currently, I have no issue with it since it does finalize the trade, but I figured it might get stuck if my other slave bots try to deal the master at the same time. How do I go about adding a timeout and retrying the deal if it fails?
  • 2. The master sitting there is a merchant and will vend after gathering the items. The issue, my slave bots would get stuck if it's not able to trade and would not continue on with the MoveToFild (Return error below). I've read that this can be solved by using eventMacro PlayerNear. Although I'm very unfamiliar with eventMacros. Can I incorporate it before calling "do deal @player()"? Hmm or maybe it would be easier if I have it automatically change lockmap if it's been idle or haven't traded after a few minutes.
This is the return error when it fails to trade and gets stuck till I reset it or change lockmap manually (if master is already on trade it says "attempting to deal" instead of not nearby otherwise "not nearby" if it does not detect or does not deal master at all)
"Unknown player [-1]. Player not nearby?
[macro log] This is the list of indexes for Guard (\$list): -1
Error in function 'deal' (Deal a Player)
There is no deal to accept"

Partially working code for anyone who needs it.

Code: Select all

automacro moveToMaster {
	eval ($field->isCity)
	call {
		do conf lockMap #Town where master is
		do conf lockMap_x
		do conf lockMap_y
		do move #Where master is located
		pause 5
	}
	run-once 1
}

automacro dealToMaster {
   location #Where master is located
   call {
      do deal @player(#MasterName)
      pause 3
	  if ($.zeny >= 200000) {
         do deal add z @eval($.zeny - 100000)
      }
      $list = @Inventory(Guard [1])
      log This is the list of indexes for Guard (\$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
		pause 1
		 do deal
		pause 1
	  do deal
	}
	run-once 1
}


automacro moveToFild {
	console /Deal Complete/i
	call {
		do conf lockMap #farming map
		do conf lockMap_x none
		do conf lockMap_y none
		do move #farming map
		do reload macro
	}
}

hakore
Super Moderators
Super Moderators
Posts: 214
Joined: 16 May 2008, 08:28
Noob?: No
Contact:

Re: Can anyone help me with a couple series of Macros?

#13 Post by hakore »

You can probably split dealToMaster into two macros to correspond to two stages.

First is the deal attempt that will retry after every x seconds until the deal window appeared.

The second one will trigger when the deal request was accepted and locks the first macro. This will contain all the deal add commands.

Plan the matching release commands.

There are ways to check the presence of the player. Try to search for it. I'm not an expert in macros, I'm just basing on the syntax via the manual.
Whatever...

ytbro00
Noob
Noob
Posts: 14
Joined: 01 Aug 2017, 16:44
Noob?: No

Re: Can anyone help me with a couple series of Macros?

#14 Post by ytbro00 »

Tried to read up on the macros and checks but it's starting to get too complicated from there. I did a workaround, instead of having them come automatically, I made a macro so that when I trigger a macro on my master, it sends my bots a pm. When they receive the message, they use bwing and proceeds on the trade, after trading the master bot would then send it to the next bot. This way they wouldn't get stuck and will continue to do their normal routine even if my merchant is not there.

Last thing I need help with is taking items from storage. I have my slave farmers still do auto storage to prevent overweight status. With the code you gave me, I modified it for storage. What I currently have would successfully take all items that I need, in this case Mace[4]. After taking the items, it would then show me a syntax error and would not close storage or continue trading. Would you happen to know how to solve this?

This is what I currently have. I tried with & without the "if" and "$i" as well but still gave me the syntax errors. Commented out talk npc and resp while testing macro.

Code: Select all

automacro StorageGetItems {
   call {
          #do talk @npc (#coordinates)
	  #do talk resp 1
      pause 3
      $list = @Storage(Mace [4])
      log List of Maces in storage (\$list): $list
      while ("$list" != "-1" && "$list" != "") as loop
      $item = [$list]
      do storage get $item
      end loop
		pause 1
		 storage close
	}
	run-once 1
	}

Last edited by ytbro00 on 18 Aug 2017, 06:12, edited 1 time in total.

hakore
Super Moderators
Super Moderators
Posts: 214
Joined: 16 May 2008, 08:28
Noob?: No
Contact:

Re: Can anyone help me with a couple series of Macros?

#15 Post by hakore »

Of course it would help if you post the exact error message.

I'm not sure if you just missed deleting enough lines, but you have an extra "}" somewhere, I don't know if that contributes to the error.

BTW, good job on your workarounds.
Whatever...

ytbro00
Noob
Noob
Posts: 14
Joined: 01 Aug 2017, 16:44
Noob?: No

Re: Can anyone help me with a couple series of Macros?

#16 Post by ytbro00 »

Oh right. Sorry did a poor job on editing what I posted on the reply. A little too tired and forgot to post the error as well, but yes the current code does not have a bracket. I edited my post above to reflect that actual one that I currently have.

Anyway, even with or without the "if" & "$i" or the extra bracket, this is still the error.
[macro] StorageGetItems.call error: error in 8: syntax error

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: Can anyone help me with a couple series of Macros?

#17 Post by Mortimal »

Sorry i am really out of topic here, but do u really need loop for this? U can get list from storage guys:

Code: Select all

$list = @Storage(some shit)
do storage get $list
To get all items.... in $list


Aw lol there is no such thing in OpenKore manual but it is in OpenKore code x)


Upd.
Hmmmmm i think we need to add a limit to Macro plugin's getStorageIDs sub so we can write sms like @Storage("Some shit", 10)
Please use pin function for uploading your file contents!

ytbro00
Noob
Noob
Posts: 14
Joined: 01 Aug 2017, 16:44
Noob?: No

Re: Can anyone help me with a couple series of Macros?

#18 Post by ytbro00 »

Even without the loop and enter this

Code: Select all

automacro StorageGetItems {
   call {
      $list = @Storage(Mace [4])
      do storage get $list
		pause 1
		 storage close
	}
	run-once 1
	}
It still returns a syntax error
[macro] StorageGetItems.call error: error in 3: syntax error

Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Re: Can anyone help me with a couple series of Macros?

#19 Post by Mortimal »

don't use call {} use call x macro x{} instead... Mace [4] is it really like that in your storage? do log $list and show pls
Please use pin function for uploading your file contents!

ytbro00
Noob
Noob
Posts: 14
Joined: 01 Aug 2017, 16:44
Noob?: No

Re: Can anyone help me with a couple series of Macros?

#20 Post by ytbro00 »

Sorry. call x macro x{}? Just started reading the manual. Not really well versed in making macros yet.

log $list
Image

Post Reply