05/13 zip event parsing question

For questions regarding conversion of scripts from the old, parm style to the new MQ2Data format. Conversion questions only!

Moderator: MacroQuest Developers

fantum409
a ghoul
a ghoul
Posts: 141
Joined: Fri Nov 14, 2003 10:03 pm

05/13 zip event parsing question

Post by fantum409 » Fri May 14, 2004 11:12 pm

OK, I'm using the 05/13/04 [and 5/14 zip] zip, and having problems with event parsing. This excerpt from my macro will respond apropriately at first, and begin following me when my main says "Follow me bitches" to the specified chat room. But it no longer stops following once in follow mode. I've rearranged the punctuation a bit and havent found the solution yet. This was working before the event changes.

Code: Select all

#event Followme "#*#Follow me bitches#*#" 
#event Endfollow "#*#Stop following me bitches#*#"
#Chat chat mysecretroom


Sub Main
/declare Following outer 
/declare FollName outer
/varset FollName ${Target}


Sub Event_Followme 
/varset Following 1 
/target ${FollName}
:Loop 
/face fast 
/if (${Target.Distance}>10) /keypress forward hold 
/if (${Target.Distance}<9) /keypress back 
/doevents
/if (!${Target.ID}) /varset Following 0
/if (${Target.ID}) /if (${Following}>0) {
	/goto :Loop
	} else { 
	/keypress forward 
	/keypress back 
} 
/return 


Sub Event_Endfollow
/varset Following 0 
/keypress forward 
/keypress back 
/return 
Last edited by fantum409 on Sat May 15, 2004 2:44 am, edited 3 times in total.

Jerle69
a hill giant
a hill giant
Posts: 263
Joined: Wed Apr 28, 2004 3:26 pm

Post by Jerle69 » Fri May 14, 2004 11:45 pm

There's umm, quite a bit of excess code in here, but without nitpicking over style issues, there is one major problem for you to take a look at.

You initialize FollName with the target the character running the macro has at the time of it's execution (which may or may not be the person who says "Follow me bitches" in the secretroom.

More of an issue is that you have no main sub (which isn't required, but I'm not even sure what the behavior would be without it, presuming you have other subroutines). This is almost structured like an include file :). I'm guessing MQ2 is exeucting your Subfuction Followme as a main, and once it's executed, it will loop as long as you're in follow-mode (Following>0), but if the Endfollow event is triggered, the final "else" portion of your Followme sub will fire and cause it to reach the /return statement. At that point, your macro dies.

If I may suggest, try using a single #Chat event:

Code: Select all

Sub Event_Chat(ChatType, Sender, ChatText)
for your "Follow me bitches, and stop following me bitches" commands, and also us it to change the global follow state for your character(s).

I butchered yours a bit and wrote a new one. I haven't tested this, nor have I even tried to run it with MQ2 (there could be a syntax error in it, or possibly a logic problem).

Code: Select all

|Followme.inc 

#Chat chat mysecretroom 

Sub Main
  /declare Following bool outer FALSE

  :Loop
  /doevents
  /if (${Following}) {
    /face fast
    /if (${Target.Distance}>10) /keypress forward hold  
    /if (${Target.Distance}<9) /keypress forward 
    /if (!${Target.ID}) /varset Following FALSE
  }
  /goto :Loop
/return

Sub Event_Chat(ChatType, Sender, ChatText)
  /if (${ChatText.Equal[Follow me bitches]}) {
    /varset Following TRUE
    /target ${Sender}
  }
  /if (${ChatText.Equal[Stop following me bitches]}) {
    /varset Following FALSE
  }
/return
--Jerle

fantum409
a ghoul
a ghoul
Posts: 141
Joined: Fri Nov 14, 2003 10:03 pm

Post by fantum409 » Sat May 15, 2004 12:16 am

Well, that does look a lot more efficient. There are some reasons why I set it up to follow the initially targeted person, but I will incorporate some of the more efficient language there. Thanks.

Any reason why the event:

Code: Select all

#event Endfollow "#*#Stop following me bitches#*#" 
wouldn't trigger the sub?

Code: Select all

Sub Event_Endfollow 
/varset Following 0 
/keypress forward 
/keypress back 
/return 

I got it going by changing the event trigger to

Code: Select all

#event Endfollow "#*#End follow#*#"
Not sure why the change was needed though.

ml2517
a grimling bloodguard
a grimling bloodguard
Posts: 1216
Joined: Wed Nov 12, 2003 1:12 am

Post by ml2517 » Sat May 15, 2004 5:15 am

I would suggest not using #event for stuff that is going through chat channels. Use Jerle's method. As far as it not matching that string but matching the other. Not really sure on that.