RK420 0 Posted August 2, 2018 Hello everyone! I'm pretty new to scripting, and have been practicing by making a bot for nightmare zone. I use the MessageListener for reading the game messages and detecting my remaining absorption charges and to know when I need to drink a new dose of overload. Now my question is, how does the MessageListener interact with the OnLoop() from AbstractScript? An example in pseudocode: OnLoop() { Do_thing_1() Sleep(5000) } OnGameMessage(Message) { if (Message == "Overload is over") { Do_thing_2() Sleep(20000) } } When the overload is over, will the bot do nothing for 20 seconds, or will it still do thing 1 every 5 seconds while not reading any messages for 20 seconds? Thanks
Eclipseop 194 Posted August 2, 2018 message listeners are on a seperate thread. sleeping there will only cause that thread to sleep, not the onloop thread.
Neffarion 486 Posted August 2, 2018 Use a boolean flag, toggle it on the message listener method and check that flag on the onloop
ArmyofDragons 28 Posted August 2, 2018 You can use Widget and WidgetChild to just get the current Absorption number that is on the Nightmare Zone UI, that's what I did for my own NMZ script.
RK420 0 Author Posted August 2, 2018 4 hours ago, Neffarion said: Use a boolean flag, toggle it on the message listener method and check that flag on the onloop I've been using a boolean flag 'ovling' which indicates whether my character is drinking overload or not. Because the bot should not eat dwarven rock cake to lower its hitpoints if its ovling. This boolean flag becomes true when the message listener detects the ovl is over, but for some reason my character eats dwarven rock cake, even though its ovling. This made me think that the OnLoop() function gets called BEFORE the listener puts this boolean flag on true. Is this possible? I'm really confused right now. The message listener should get priority over the loop function, but i'm not sure that's true.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.