Monitor chat ... if event XYZ, then load WP/file

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Message
Author
User avatar
Edamh
Posts: 106
Joined: Tue May 24, 2011 11:56 pm

Monitor chat ... if event XYZ, then load WP/file

#1 Post by Edamh » Fri Nov 04, 2011 11:02 pm

Is it possible to monitor chat and if event XYZ is being broadcast, then run/load a specific WP file or specific WP within a file?

For example, I may want to bot outside OS. Then if the notice about the harpies outside OS shows up on chat, I would want the bot to load a specific WP that includes that area with the harpies. After the event (the end also being noted by another msg in chat), I would want the bot to go back to the original route outside OS.

Is possible to monitor chat and load WP accordingly? If so, any pointers or tips on how to do so? Thanks.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Monitor chat ... if event XYZ, then load WP/file

#2 Post by lisa » Sat Nov 05, 2011 12:48 am

Yup, mind you if you load a WP while you are far away from any of the new WP coords it will try to run up cliffs to get to the nearest coords of the WP. If you make the new WP cover the entire map then it would be fine.

You will need to start a monitor event.

I'll use GM detect as an example.

So you can call this function from an onload Wp or profile
startGMDetect()

Code: Select all

function startGMDetect()
	if settings.profile.options.GMDETECT == true then
		unregisterTimer("GMdetection");
		printf("GM detection started\n");
		EventMonitorStart("GMdetect", "CHAT_MSG_SYSTEM");
		registerTimer("GMdetection", secondsToTimer(5), GMdetection);
	end
end
I changed it to be CHAT_MSG_SYSTEM as you want to monitor system messages.
So this will make it do the function GMdetection() every 5 seconds.

in the GMdetection() you will need code to check for the text you want.

Code: Select all

repeat
	local time, moreToCome, name, msg = EventMonitorCheck("GMdetect", "4,1")
What you will be after is what msg means.
do a check for msg

Code: Select all

if msg ~= nil then
you want to then check to see if msg is anything like what you want, can do a string.find for that.

Code: Select all

if string.find(msg,"****") then
Obviously change the **** for what ever it is you are looking for in the message.
then just tell bot what you want to do

Code: Select all

loadPaths("**")
Add it together and looks like this

Code: Select all

repeat
local time, moreToCome, name, msg = EventMonitorCheck("GMdetect", "4,1")
if msg ~= nil then
if string.find(msg,"****") then
loadPaths("**")
end
end
until moreToCome == false
So remember this used names from the gmdetect as an example, so you should change names to what you want. It should be enough to get you started atleast.
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

User avatar
Edamh
Posts: 106
Joined: Tue May 24, 2011 11:56 pm

Re: Monitor chat ... if event XYZ, then load WP/file

#3 Post by Edamh » Sat Nov 05, 2011 7:25 am

Thanks much. Will give it a try later today.

User avatar
Edamh
Posts: 106
Joined: Tue May 24, 2011 11:56 pm

Re: Monitor chat ... if event XYZ, then load WP/file

#4 Post by Edamh » Sat Nov 05, 2011 9:53 am

So I loaded the following in the <onLoad> section of my waypoint file but the bot never started even though the system message showed up in chat. Thoughts?

Code: Select all

function startEVENTDetect()
   if settings.profile.options.GMDETECT == true then
      unregisterTimer("EVENTdetection");
      printf("EVENT detection started\n");
      EventMonitorStart("EVENTdetect", "CHAT_MSG_SYSTEM");
      registerTimer("EVENTdetection", secondsToTimer(5), EVENTdetection);
   end
end

repeat
local time, moreToCome, name, msg = EventMonitorCheck("EVENTdetect", "4,1")
if msg ~= nil then
if string.find(msg,"<START TEXT HERE>") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("START"));
end
if string.find(msg,"<END TEXT HERE>") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("GOTOSLEEP"));
end
end
until moreToCome == false

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Monitor chat ... if event XYZ, then load WP/file

#5 Post by lisa » Sat Nov 05, 2011 9:29 pm

Code: Select all

registerTimer("EVENTdetection", secondsToTimer(5), EVENTdetection);
This part makes it call a function with the name that is the 3rd argument, in this case EVENTdetection, the one without the ""

So if you do it all purely in onload of a WP then do it like this.

Code: Select all

function EVENTdetection()
repeat
local time, moreToCome, name, msg = EventMonitorCheck("EVENTdetect", "4,1")
if msg ~= nil then
if string.find(msg,"<START TEXT HERE>") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("START"));
end
if string.find(msg,"<END TEXT HERE>") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("GOTOSLEEP"));
end
end
until moreToCome == false
end

function startEVENTDetect()
      unregisterTimer("EVENTdetection");
      printf("EVENT detection started\n");
      EventMonitorStart("EVENTdetect", "CHAT_MSG_SYSTEM");
      registerTimer("EVENTdetection", secondsToTimer(5), EVENTdetection);
end

startEVENTDetect()
Don't forget the startEVENTDetect() as you still need to call the function at some stage.

This won't get you stuck in a loop though, so it will still go to the nearest set of coords when you start the WP.
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

User avatar
gloover
Posts: 304
Joined: Wed Jul 07, 2010 4:31 am

Re: Monitor chat ... if event XYZ, then load WP/file

#6 Post by gloover » Thu Jan 12, 2012 4:05 pm

Hey lisa, hi rock.

How can I realize this:

toon1 stay at the position (e.a waypoint1) until sended message (from toon2) in group chat ("come" or somesing else) was detected and how to send a message into a group-chat-frame?

thx in advance!

User avatar
grande
Posts: 261
Joined: Tue Jun 28, 2011 4:46 pm

Re: Monitor chat ... if event XYZ, then load WP/file

#7 Post by grande » Mon Sep 17, 2012 12:57 pm

Lisa, okay... so I was mincing between your "LOL" eventmonitortest and an attempt to --make it work-- with monitoring system chat and then I stumbled on this post.

This works fine but I want to try something else, further down

Code: Select all

<!-- #  1 --><waypoint x="-18556" z="-18129" y="999"> EventMonitorStart("Test", "CHAT_MSG_SAY");
sendMacro("SendChatMessage('LOL','SAY');")
yrest(1000)
local time, moreToCome, msg = EventMonitorCheck("Test", "1") if string.find(msg, "LOL") then printf("Event monitoring works fine.\n")
player:sleep()
end
</waypoint>
</waypoints>

The code below gives a string error. Studied a bit and learned string.find is looking for the text. Unfortunately it doesn't seem like the system chat gets logged the same OR (more likely) I'm assigning the event monitor incorrectly. I read about EventMonitorCheck saving to a log... is this a real-time log or is it saved somewhere I can view?

Code: Select all

<!-- #  1 --><waypoint x="-18556" z="-18129" y="999"> EventMonitorStart("Test", "CHAT_MSG_SYSTEM"); 
sendMacro("SendSystemChat(PE_GetPOBInfo( 1 , 0 ),'SYSTEM');")
yrest(1000)
local time, moreToCome, msg = EventMonitorCheck("Test", "1") 
if string.find(msg, "Time remaining") then 
printf("Event monitoring works fine.\n")
player:sleep()
end
</waypoint>
</waypoints>
Another swing and a miss as I tried to make the code look more like yours LOL

Code: Select all

<!-- #  1 --><waypoint x="-18556" z="-18129" y="999"> EventMonitorStart("Test", "CHAT_MSG_SYSTEM"); 
sendMacro("SendSystemChat(PE_GetPOBInfo( 1 , 0 ),'SYSTEM');")
yrest(1000)
local time, moreToCome, msg = EventMonitorCheck("Test", "1") if string.find(msg, "PE_GetPOBInfo( 1 , 0 )") then printf("Event monitoring works fine.\n")
player:sleep()
end
</waypoint>
</waypoints>
So now, after reading this thread it looks like my solution is this?

Code: Select all

</onLoad>

function EVENTdetection()
repeat
local time, moreToCome, name, msg = EventMonitorCheck("EVENTdetect", "4,1")
if msg ~= nil then
if string.find(msg,"Positive Effect") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("START"));
end
if string.find(msg,"Time remaining") then
__WPL:setWaypointIndex(__WPL:findWaypointTag("GOTOSLEEP"));
end
end
until moreToCome == false
end

function startEVENTDetect()
      unregisterTimer("EVENTdetection");
      printf("EVENT detection started\n");
      EventMonitorStart("EVENTdetect", "CHAT_MSG_SYSTEM");
      registerTimer("EVENTdetection", secondsToTimer(5), EVENTdetection);
end

startEVENTDetect()
</onLoad>
And then at a WP

Code: Select all

<!-- #  1 --><waypoint x="-18556" z="-18129" y="999"> 
sendMacro("SendSystemChat(PE_GetPOBInfo( 1 , 0 ),'SYSTEM');")
yrest(100)
EVENTdetection()
</waypoint>
</waypoints>
So I changed the system message to look for above to "Positive Effect" and "Time remaining" based on what I know "sendMacro("SendSystemChat(PE_GetPOBInfo( 1 , 0 ),'SYSTEM');")" will return in the system chat window.

Once startEVENTDetect() is initiated in the /onLoad section do I need to call it again at a specific WP or does it just run continually as long as the WP is running?

Thx again and again

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

Re: Monitor chat ... if event XYZ, then load WP/file

#8 Post by rock5 » Mon Sep 17, 2012 1:17 pm

Why do you want to do this? Why print the values returned from the function and then monitor the chat, when you can just return the values from the function?

Code: Select all

local namePOB , itype , ikind , nowvalue, doolsill = RoMScript("PE_GetPOBInfo( 1 , 0 )")
I'm not sure what the returned values are but I copied those variable names from the publicencounterframe.lua file.
  • 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
grande
Posts: 261
Joined: Tue Jun 28, 2011 4:46 pm

Re: Monitor chat ... if event XYZ, then load WP/file

#9 Post by grande » Mon Sep 17, 2012 1:24 pm

The "PE_GetPOBInfo( 1 , 0 )" gives different outputs such as "Positive Effect" and "Time remaining". I want it to do different WP based on that text. I don't know how to make "local namePOB , itype , ikind , nowvalue, doolsill = RoMScript("PE_GetPOBInfo( 1 , 0 )")" do that.

However, the event monitor test seemed like a way. If it would print something then surely it would load a waypoint.

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

Re: Monitor chat ... if event XYZ, then load WP/file

#10 Post by rock5 » Mon Sep 17, 2012 2:44 pm

Its simple really. PE_GetPOBInfo( 1 , 0 ) is an ingame function that returns 5 values. When you use

Code: Select all

/script SendSystemChat(PE_GetPOBInfo( 1 , 0 ))
you are telling it to print the values the function returns but because SendSystemChat can't print multiple values it only prints the first. If you wanted to you could do this

Code: Select all

/script aa,bb,cc,dd,ee = PE_GetPOBInfo( 1 , 0 )
and then print each of those 5 values.

Now in the bot, if you use

Code: Select all

msg = RoMScript("PE_GetPOBInfo( 1 , 0 )")
because there is only one variable it will only capture the first value which is the one you've been playing with. But if you want to look at all the values that function returns you could do

Code: Select all

aa,bb,cc,dd,ee = RoMScript("PE_GetPOBInfo( 1 , 0 )")
RoMScript can return any values, variables or function outputs just like they do in game.

Hope that helps.
  • 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
grande
Posts: 261
Joined: Tue Jun 28, 2011 4:46 pm

Re: Monitor chat ... if event XYZ, then load WP/file

#11 Post by grande » Mon Sep 17, 2012 10:06 pm

Ahhh.... edit here.. lol. Think I got it. So "namePOB" was the key I couldn't seem to grasp. right there in front of my face. grrrr

Code: Select all

	<!-- #  1 --><waypoint x="1" z="9" y="8">	
		EventMonitorStart("Test", "CHAT_MSG_SYSTEM");
		sendMacro("SendSystemChat(PE_GetPOBInfo( 1 , 0 ));")
		yrest(1000)	
		local namePOB = RoMScript("PE_GetPOBInfo( 1 , 0 )")
			if string.find(namePOB, "Positive Effect") then
				printf("Positive Effect!!!!.\n")
			else
			if string.find(namePOB, "Time remaining") then
				printf("Time remaining!!!!.\n")
			end
			end			
</waypoint>
omgosh i must need sleep or more than 24 hours in a day. don't know how you guys get it. I blame my lack of attention to detail as diminished by lack of sleep. menal acuity shot need zzzzzzZZZZzzzZZZzz

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Monitor chat ... if event XYZ, then load WP/file

#12 Post by lisa » Tue Sep 18, 2012 12:41 am

I think the point you seem to be missing is you don't need to monitor chat or print it.

try this.

Code: Select all

   <!-- #  1 --><waypoint x="1" z="9" y="8">    
      local namePOB = RoMScript("PE_GetPOBInfo( 1 , 0 )")
         if string.find(namePOB, "Positive Effect") then
            printf("Positive Effect!!!!.\n")
         elseif string.find(namePOB, "Time remaining") then
            printf("Time remaining!!!!.\n")
else print("value returned is "..namePOB)
         end
</waypoint>
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

User avatar
grande
Posts: 261
Joined: Tue Jun 28, 2011 4:46 pm

Re: Monitor chat ... if event XYZ, then load WP/file

#13 Post by grande » Tue Sep 18, 2012 6:53 am

Thanks so much again. For this part:

Code: Select all

else print("value returned is "..namePOB)
seems it returns w/e else the current status of namePOB is but why are the ".." in front of namePOB needed?

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: Monitor chat ... if event XYZ, then load WP/file

#14 Post by BillDoorNZ » Tue Sep 18, 2012 7:25 am

the .. concatenates the two strings together

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Monitor chat ... if event XYZ, then load WP/file

#15 Post by lisa » Tue Sep 18, 2012 7:48 am

grande wrote:but why are the ".." in front of namePOB needed?
Ok a string is any text inside " "
So "lollies" is a string
a variable is something that has a value, defined or not.

lollies = "fruit"

As an example if you have this

Code: Select all

lollies = "Fruit"
print("Lollies "..lollies)
it will print

Code: Select all

Lollies Fruit
You need the .. to tell MM that the next thing is a variable and you want it used with the string. I can't think of a better way to explain it.

So as extra info

print("Lollies "..lollies.." are yummy")
will print
Lollies Fruit are yummy
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

User avatar
grande
Posts: 261
Joined: Tue Jun 28, 2011 4:46 pm

Re: Monitor chat ... if event XYZ, then load WP/file

#16 Post by grande » Tue Sep 18, 2012 1:24 pm

Ahh yes, excellent thx again and again and again Lisa. your description makes it crystal clear.

So the ".." pulls out whatever may be the current result/status of the namePOB equation.

Like Bill said, concatenates the string component namePOB to whatever the current status is.

If it's blank, as in on a bugged channel would it just fail and stop the MM or would it just print nil? I can mess with it later.

User avatar
Edamh
Posts: 106
Joined: Tue May 24, 2011 11:56 pm

Re: Monitor chat ... if event XYZ, then load WP/file

#17 Post by Edamh » Fri Nov 16, 2012 10:47 am

I am trying to monitor party chat, and I am trying to use the code above. Here's what I have:

Code: Select all

function EVENTdetection()
	repeat
	cprintf(cli.yellow,"Inside EVENTdetection function; inside repeat ... until \n");
	local time, moreToCome, name, msg = EventMonitorCheck("EVENTdetect", "4,1")
	if msg ~= nil then
		if string.find(msg,"msg1") then
			cprintf(cli.lightblue,"msg1 received in PARTY chat. \n");
			__WPL:setWaypointIndex(__WPL:findWaypointTag("START"));

		end
		if string.find(msg,"msg2") then
			cprintf(cli.lightblue,"msg2 received in PARTY chat. \n");
			__WPL:setWaypointIndex(__WPL:findWaypointTag("SLEEP"));
		end
	end
	until moreToCome == false
end

function startEVENTDetect()
      unregisterTimer("EVENTdetection");
      printf("EVENT detection started\n");
      EventMonitorStart("EVENTdetect", "CHAT_MSG_PARTY");
      registerTimer("EVENTdetection", secondsToTimer(10), EVENTdetection);
end
I can trigger the print line to show that msg1 or msg2 are received. However, the code loops infinitely displaying my yellow screen prints, and doesn't escape the repeat ... until in function EVENTdetection

What am I missing? How do I escape the repeat ... until and actually go to the specified waypoints? Thanks.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Monitor chat ... if event XYZ, then load WP/file

#18 Post by lisa » Fri Nov 16, 2012 7:02 pm

The code itself looks fine, only thing I can come up with is the timer is set to 10 seconds, so if you type in party chat a few times before it actually calls the function then it will print in MM for each time.

Try setting it to 1 second calls and see if it helps.

Code: Select all

registerTimer("EVENTdetection", secondsToTimer(1), EVENTdetection);
As a side note I added some functions to party.lua to make it easier to monitor party chat.
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

User avatar
Edamh
Posts: 106
Joined: Tue May 24, 2011 11:56 pm

Re: Monitor chat ... if event XYZ, then load WP/file

#19 Post by Edamh » Fri Nov 16, 2012 9:18 pm

lisa wrote:The code itself looks fine, only thing I can come up with is the timer is set to 10 seconds, so if you type in party chat a few times before it actually calls the function then it will print in MM for each time.

Try setting it to 1 second calls and see if it helps.

Code: Select all

registerTimer("EVENTdetection", secondsToTimer(1), EVENTdetection);
As a side note I added some functions to party.lua to make it easier to monitor party chat.
I tried changing the 10 seconds to 1, but it still doesn't escape the repeat...until. Here's what shows up in the MM window:Image The bot just stands there, then.

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

Re: Monitor chat ... if event XYZ, then load WP/file

#20 Post by rock5 » Fri Nov 16, 2012 11:27 pm

Just because it keeps printing that message doesn't necessarily mean it's stuck in that loop. It might be stuck somewhere else and the timed event is doing it's thing every second. Where did you start monitoring the event? How did you start it? If you comment out the line that starts the monitor does it still get stuck?
  • 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

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 27 guests