Triggering event directly after Pause

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
amalia
Posts: 38
Joined: Wed Jul 10, 2013 7:37 am

Triggering event directly after Pause

#1 Post by amalia »

I wonder if there is a possibility to trigger an event directly after resuming the bot manually from pause.

e.g. searching for nearest waypoint, after playing manually for a while.
The onskillcastevent is not so useful it force you to dismount and messes up since is always called.
Maybe the eventmonitor can used for it but I dont know how.

Edit
Following code added to the onload section of a waypoint works well.
Don´t use it in selfcrossing waypoints and demand of continously doing things.


Code: Select all

<onload>
<!--- ......--->

function myResumeCallback()
resumeCallback()  
 player:updateXYZ();
    __WPL:setWaypointIndex(__WPL:getNearestWaypoint(player.X, player.Z));
end
atResume(myResumeCallback) -- sets the resume callback function
</onload>
Last edited by amalia on Fri Aug 02, 2013 3:08 am, edited 2 times in total.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Triggering event directly after Pause

#2 Post by rock5 »

MM is set up to execute what are called callback functions when a script is paused, resumed, errors or terminates normally. So it's very easy to do. Here is some sample code.

Code: Select all

function myResumeCallback()
    resumeCallback() -- call the original callback function.
    -- your code here
end
atResume(myResumeCallback) -- sets the resume callback function
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
amalia
Posts: 38
Joined: Wed Jul 10, 2013 7:37 am

Re: Triggering event directly after Pause

#3 Post by amalia »

hey rock

I gave it a try lik that in my waypointfile

Code: Select all

<onload>
.......

function myResumeCallback()
      print("function called");
      __WPL:setWaypointIndex(__WPL:getNearestWaypoint(player.X, player.Z));
end
atResume(myResumeCallback) -- sets the resume callback function
</onload>
edit
then i paused, walked away near to another waypoint and resumed. the bot still tries to continue where it was last time. Debug message IS printed.
Do I use it wrong?


update
When I pause the game and resume it once, no new waypoint is set.
If I pause it, resume it, pause it and resume it again then it works as it should.

It works for me but it feels strange.
So thank you for the hint.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Triggering event directly after Pause

#4 Post by rock5 »

You need to update the player coordinates. Add a

Code: Select all

player:updateXYZ()
before the setWaypointIndex.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
User avatar
Ego95
Posts: 564
Joined: Tue Feb 28, 2012 12:38 pm
Contact:

Re: Triggering event directly after Pause

#5 Post by Ego95 »

I like your idea. Wouldn't is be best to add this as default to the bot?

AlterEgo95
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Triggering event directly after Pause

#6 Post by rock5 »

Not really. There are times when this would cause problems. Example, when you have a complex waypoint file that crisscrosses the same area multiple times. If you pause the script you wouldn't want it to jump to another part of the waypoint file just because the waypoint is closer and bypass necessary waypoints. We are usually very wary about using "__WPL:setWaypointIndex(__WPL:getNearestWaypoint(player.X, player.Z));" for that reason.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
User avatar
Ego95
Posts: 564
Joined: Tue Feb 28, 2012 12:38 pm
Contact:

Re: Triggering event directly after Pause

#7 Post by Ego95 »

Ok, I agree with you. Then maybe add it to the bot and add a profile option which is set to false by default :P

Really great idea. I'll add this to all my scripts :) thanks
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Triggering event directly after Pause

#8 Post by rock5 »

Ideally it would depend on the waypoint file. You wouldn't want it enabled on complex files but you might want it enabled on simpler files. I'm happy to leave it as it is. It's easy enough to add the above code to the waypoint files and allows the user customize the waypoint selection based on that waypoint file, if they wish.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
amalia
Posts: 38
Joined: Wed Jul 10, 2013 7:37 am

Re: Triggering event directly after Pause

#9 Post by amalia »

Just for the reason of copy and paste.

I edited the first post with the perfectly working code. Thanks to rock.
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Triggering event directly after Pause

#10 Post by lisa »

you forgot to add in the

Code: Select all

resumeCallback()
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
amalia
Posts: 38
Joined: Wed Jul 10, 2013 7:37 am

Re: Triggering event directly after Pause

#11 Post by amalia »

I thought somehow this was optional since it is "the orginal one" and I want another one.
Ok I added and changed in working code

Thanks
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Triggering event directly after Pause

#12 Post by rock5 »

You could leave it out but the original function does some things that you would still want it to do.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
Post Reply