Page 2 of 2

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

Posted: Sat Nov 17, 2012 12:21 am
by Edamh
rock5 wrote: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?
Here's how it looks:

Code: Select all

   <!-- #  1 --><waypoint x="-1" z="-1" y="1" type="TRAVEL" tag="START">
--   startEVENTDetect()
   player:mount();
   player:target_NPC("NPCName");
   yrest(100);
   AcceptQuestByName("QuestName");
   yrest(100);
   </waypoint>
If I comment out the line that starts the monitor, the WP file runs as expected.

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

Posted: Sat Nov 17, 2012 12:35 am
by lisa
is there just 1 waypoint?
If so that would explain it, the startEVENTDetect is being called repeatedly, try putting that in the onload. The timer will take care of the rest, so only needs calling once.

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

Posted: Sat Nov 17, 2012 1:55 am
by Edamh
There are 8 waypoints. #1-5 loop through area; #6-8 are for walking to rest/sleep area.

Moving the startEVENTDetect() to the onload produces same wall of yellow printscrns.

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

Posted: Sat Nov 17, 2012 2:58 am
by lisa
try changing it to

Code: Select all

until msg == nil
At some stage I started to use that instead of the until moretocome == false, can't remember why.
Edamh wrote:There are 8 waypoints. #1-5 loop through area; #6-8 are for walking to rest/sleep area.
so you also want to stop and start the event monitoring at different waypoints?

Also try adding in a little yrest inside the loop

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

Posted: Sat Nov 17, 2012 3:22 am
by rock5
I think the problem is, even though moreToCome will be true if there are more to come, it won't necessarily be false if there isn't.

Try changing

Code: Select all

until moreToCome == false
to

Code: Select all

until moreToCome ~= true

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

Posted: Sat Nov 17, 2012 3:45 am
by lisa
rock5 wrote:I think the problem is, even though moreToCome will be true if there are more to come, it won't necessarily be false if there isn't.
That is probably why I started to use until msg == nil

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

Posted: Sat Nov 17, 2012 8:52 am
by Edamh
rock5 wrote:I think the problem is, even though moreToCome will be true if there are more to come, it won't necessarily be false if there isn't.

Try changing

Code: Select all

until moreToCome == false
to

Code: Select all

until moreToCome ~= true
Changing the code to

Code: Select all

until moreToCome ~= true
did the trick. Thank you for the help.


Here's the code that I'm using now:

Code: Select all

<onload>
function EVENTdetection()
	repeat
	cprintf(cli.yellow,"Inside EVENTdetection function; inside repeat ... until \n");
	yrest(300);
	local time, moreToCome, name, msg = EventMonitorCheck("EVENTdetect", "4,1") 
	if msg ~= nil then
		if string.find(msg,"EventSTART") then
			cprintf(cli.lightblue,"EventSTART received in PARTY chat. \n");
			__WPL:setWaypointIndex(__WPL:findWaypointTag("START"));
			partyCHATmsg = "EventSTART"
		end
		if string.find(msg,"EventSTOP") then
			cprintf(cli.lightblue,"EventSTOP received in PARTY chat. \n");
			__WPL:setWaypointIndex(__WPL:findWaypointTag("Home Base"));
			partyCHATmsg = "EventSTOP"
		end
	end
	until moreToCome ~= true
end
function startEVENTDetect()
      unregisterTimer("EVENTdetection");
      printf("EVENT detection started\n");
      EventMonitorStart("EVENTdetect", "CHAT_MSG_PARTY");
      registerTimer("EVENTdetection", secondsToTimer(1), EVENTdetection);
end
startEVENTDetect()
</onload>