Page 1 of 1

Monitoring Starting Message

Posted: Sat Nov 23, 2013 2:23 am
by Danni
Hi,

I would like to use following codes to check if the "Event is starting" if not the char should just rest until the event start. For that purpose I want to use the functions getLastWarning or getLastAlert. It would be rather helpful, if it works, so MM can run independent without the clock.

I tried 4 different codes in order to work it out:

Code: Select all

Solution A
function EventStart()
	local strmsg = "|cffffff80"..getTEXT("Regional event now restarting!").."|r"
	print("strmsg is ".. strmsg)
       	local msgtime = getLastWarning(strmsg) or 0
        	print("msgtime is "..msgtime)       	
      	repeat
        	yrest(1500)
               	local newstrtime = getLastWarning(strmsg) or 0
      		print("newstrtimes is "..newstrtime)
	until newstrtime  > msgtime
      	print("strmsg detected")

Solution B
function EventStart()
	local strmsg = "|cffffff80"..getTEXT("Regional event now restarting!").."|r"
	print("strmsg is ".. strmsg)
       	local msgtime = getLastAlert(strmsg) or 0
        	print("msgtime is "..msgtime)       	
      	repeat
        	yrest(1500)
               	local newstrtime = getLastAlert(strmsg) or 0
      		print("newstrtimes is "..newstrtime)
	until newstrtime  > msgtime
      	print("strmsg detected")

Solution C
function EventStart()
	local strmsg = getTEXT("Regional event now restarting!")
	print("strmsg is ".. strmsg)
       	local msgtime = getLastAlert(strmsg) or 0
       	 print("msgtime is "..msgtime)       	
      	repeat
        	yrest(1500)
               	local newstrtime = getLastAlert(strmsg) or 0
      		print("newstrtimes is "..newstrtime)
	until newstrtime  > msgtime
      	print("strmsg detected")

Soution D
function EventStart()
	local strmsg = getTEXT("Regional event now restarting!")
	print("strmsg is ".. strmsg)
       	local msgtime = getLastWarning(strmsg) or 0
       	 print("msgtime is "..msgtime)       	
      	repeat
        	yrest(1500)
               	local newstrtime = getLastWarning(strmsg) or 0
      		print("newstrtimes is "..newstrtime)
	until newstrtime  > msgtime
      	print("strmsg detected")
Unfortunately, ALL 4 Solutions do not work. :arrow: MM seems not find the Message since it is only showing:
newstrtimes is 0
newstrtimes is 0
newstrtimes is 0
newstrtimes is 0
The Question is , how can I make it work? Are the functions "getLastWarning" / getLastAlert the only options I can use? Or are there any other codes to check for Messages in the Zone chat? :?:

Re: Monitoring Starting Message

Posted: Sat Nov 23, 2013 9:38 am
by rock5
The first one is the closest to being correct. As far as I know the message is a 'warning' message and it has color information that makes it yellow.

As I stated previously, that is the wrong way to use getTEXT. You should do the string 1 of 2 way. Use local language which means users of other languages wont be able to use it, eg.

Code: Select all

local strmsg = "|cffffff80Regional event now restarting!|r"
or you use getTEXT to get the local language version of the string. To do this you need to know the key string. In this case you could do.

Code: Select all

local strmsg = "|cffffff80"..getTEXT("SC_ZONE_PE_3TH_ST1START").."|r"
Something I didn't realize before is there is a small bug in getTEXT. Normally if you use an invalid keystring in getTEXT you get that string back. So I thought getTEXT("Regional event now restarting!") would just return "Regional event now restarting!" so it should have worked anyway but because that exact string exists in memory, it thinks it is a valid keystring and returns the next string after it. Which happens to be "SC_ZONE_PE_3TH_TOPLIST". So you were actually getting "|cffffff80SC_ZONE_PE_3TH_TOPLIST|r" which is not what you want. There is actually no easy way to fix that so I'm going to leave it. Just make sure you don't incorrectly use getTEXT in the future.

Re: Monitoring Starting Message

Posted: Sat Nov 23, 2013 6:11 pm
by Danni
Thu rock for your reply, ;)

I will keep that knowlege , so I won't mix it again.

But I was indeed quite surprise about the gettext bug :) Got the same message and thought it was wrong :) But since I didn't know the other code I couldn't fix it :roll: