Executing lua code after waypoints file load

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
x_art
Posts: 23
Joined: Thu Jun 11, 2009 2:22 am

Executing lua code after waypoints file load

#1 Post by x_art » Mon Nov 30, 2009 3:31 am

Is it possible to execute a lua code after waypoints file load? Situation: I harvest resources in different locations. I would to change some profile options (harvest range for example) for each location. I can put this code within a waypoint, but the bot can start from any waypoint and therefore the option will be changed after some time. I can create a different profile for each location, but this requires multiple identical profile files.

User avatar
Administrator
Site Admin
Posts: 5329
Joined: Sat Jan 05, 2008 4:21 pm

Re: Executing lua code after waypoints file load

#2 Post by Administrator » Mon Nov 30, 2009 9:33 am

You could put it in your profile's onLoad event. You'll just have to check which file is loaded.

Code: Select all

<onLoad><![CDATA[
  local wpname = settings.profile.options.WAYPOINTS;

  if( settings.profile.options.PATH_TYPE == "waypoints" ) then
    if( wpname == "whatever1" ) then
      -- do stuff for waypoint list #1
    elseif( wpname == "whatever2" ) then
      -- do stuff for waypoint list #2
    else
      -- default stuff
    end;
  end
]]</onLoad>
The problem with this is that it reads directly out of the profile which waypoint list to look for and will not be affected by forced profile changes (by using path:whatever in the command line).

x_art
Posts: 23
Joined: Thu Jun 11, 2009 2:22 am

Re: Executing lua code after waypoints file load

#3 Post by x_art » Mon Nov 30, 2009 9:41 am

Administrator wrote:You could put it in your profile's onLoad event. You'll just have to check which file is loaded.
The problem with this is that it reads directly out of the profile which waypoint list to look for and will not be affected by forced profile changes (by using path:whatever in the command line).
Thank you for this solutions that is more useful in my case. But I think that this solution will not work I'll load waypoitnts from a code with help of loadPaths("") function. Will be the onLoad event triggered at this time?

User avatar
Administrator
Site Admin
Posts: 5329
Joined: Sat Jan 05, 2008 4:21 pm

Re: Executing lua code after waypoints file load

#4 Post by Administrator » Mon Nov 30, 2009 9:55 am

onLoad is triggered when a profile is loaded, not a waypoint file, so no. You can, however, use loadPaths() within this segment and it will override the normal waypoint loading so you can accomplish what you want. The only real change to the code I posted earlier is that you need to add loadPaths(wpname, settings.profile.options.RETURN_PATH) right under the line that sets wpname.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest