Openkore.com

OpenKore Forums
It is currently 13 Dec 2017, 22:21

All times are UTC - 5 hours [ DST ]





Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Can anyone help me with a couple series of Macros?
PostPosted: 17 Aug 2017, 09:13 
Offline
Super Moderators
Super Moderators
User avatar

Joined: 16 May 2008, 08:28
Posts: 218
Try this:
Code:
while ("$list" != "-1" && "$list" != "") as loop

_________________
Whatever...


Top
 Profile  
 
 Post subject: Re: Can anyone help me with a couple series of Macros?
PostPosted: 17 Aug 2017, 11:41 
Offline
Noob
Noob

Joined: 01 Aug 2017, 16:44
Posts: 14
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)

Quote:
"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:
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
   }
}


Top
 Profile  
 
 Post subject: Re: Can anyone help me with a couple series of Macros?
PostPosted: 17 Aug 2017, 17:44 
Offline
Super Moderators
Super Moderators
User avatar

Joined: 16 May 2008, 08:28
Posts: 218
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...


Top
 Profile  
 
 Post subject: Re: Can anyone help me with a couple series of Macros?
PostPosted: 18 Aug 2017, 03:57 
Offline
Noob
Noob

Joined: 01 Aug 2017, 16:44
Posts: 14
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:
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.

Top
 Profile  
 
 Post subject: Re: Can anyone help me with a couple series of Macros?
PostPosted: 18 Aug 2017, 05:51 
Offline
Super Moderators
Super Moderators
User avatar

Joined: 16 May 2008, 08:28
Posts: 218
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...


Top
 Profile  
 
 Post subject: Re: Can anyone help me with a couple series of Macros?
PostPosted: 18 Aug 2017, 06:15 
Offline
Noob
Noob

Joined: 01 Aug 2017, 16:44
Posts: 14
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.

Quote:
[macro] StorageGetItems.call error: error in 8: syntax error


Top
 Profile  
 
 Post subject: Re: Can anyone help me with a couple series of Macros?
PostPosted: 18 Aug 2017, 06:30 
Offline
Developers
Developers

Joined: 01 Nov 2008, 15:31
Posts: 353
Sorry i am really out of topic here, but do u really need loop for this? U can get list from storage guys:
Code:
$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!


Top
 Profile  
 
 Post subject: Re: Can anyone help me with a couple series of Macros?
PostPosted: 18 Aug 2017, 11:15 
Offline
Noob
Noob

Joined: 01 Aug 2017, 16:44
Posts: 14
Even without the loop and enter this

Code:
automacro StorageGetItems {
   call {
      $list = @Storage(Mace [4])
      do storage get $list
      pause 1
       storage close
   }
   run-once 1
   }


It still returns a syntax error
Quote:
[macro] StorageGetItems.call error: error in 3: syntax error


Top
 Profile  
 
 Post subject: Re: Can anyone help me with a couple series of Macros?
PostPosted: 18 Aug 2017, 11:17 
Offline
Developers
Developers

Joined: 01 Nov 2008, 15:31
Posts: 353
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!


Top
 Profile  
 
 Post subject: Re: Can anyone help me with a couple series of Macros?
PostPosted: 18 Aug 2017, 11:30 
Offline
Noob
Noob

Joined: 01 Aug 2017, 16:44
Posts: 14
Sorry. call x macro x{}? Just started reading the manual. Not really well versed in making macros yet.

log $list
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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 © 2000, 2002, 2005, 2007 phpBB Group