Custom Event Loop

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

Insipid
decaying skeleton
decaying skeleton
Posts: 9
Joined: Sun Aug 08, 2004 12:15 pm

Custom Event Loop

Post by Insipid » Sun Aug 08, 2004 12:44 pm

Heya all! Made a custom event to handle some commands in one of my macros. When the event fires, it loops endlessly. I had to put in a /doevents flush to stop it from happening. Is that the proper way of doing it? Here's a snipped to illustrate my question:

Code: Select all

#turbo 15
#Event	CastCommand 	"#1# tells you, 'CAST #2# [[#3#]]'"

Sub Main

	/echo Test Event Macro initiated.

:MainLoop

	/doevents
	/delay 10
	/goto :MainLoop

/return

 
Sub Event_CastCommand(CastLine, CastTell, CastSpell, CastTarget)

	/echo CastCommand: ${CastLine}
	/echo Tell = ${CastTell}, Spell = ${CastSpell}, Target = ${CastTarget}
	/delay 10
	/doevents flush
	
/return
It seems a little extreme to have to do that. A quick search didn't turn up too much, so I'm wondering if the flush is really necessary or if there's some smooth command I should be using to clear this particular event.
- Insipid

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Sun Aug 08, 2004 1:25 pm

Actually you trigger the event again by echoing the text that triggered it. Remove the line that echos ${CastLine}.

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Sun Aug 08, 2004 2:11 pm

lol

Insipid
decaying skeleton
decaying skeleton
Posts: 9
Joined: Sun Aug 08, 2004 12:15 pm

HAHAH!

Post by Insipid » Sun Aug 08, 2004 7:54 pm

I r Stupid!! Thx Ninja.

Edit: Actually, why would it trigger the #Event again? Wouldn't it require '#*#' at the first since 'CastCommand: ' is echo'd in front of it?
- Insipid

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Mon Aug 09, 2004 4:44 am

No, #1# would match all the stuff before " tells you".