NotHere wrote:Got a bit further.
Code: Select all
#event SpellFaded " has worn off."
Sub Main
:Loop
/doevents
/goto :Loop
/return
Sub Event_SpellFaded
/echo SpellFaded: @Param0
/doevents flush
/return
This works fine and dandy. Is this the right way to do it?
Also, Im a bit in doubt what happens, if say, the /doevents are only done once every 5 seconds, and two spells fades inside that same period.
Would it be triggered twice, or only once (and with what inside the param?)
More elegant way to do it (Off to look at twist.mac too)?
*chuckle*
Been there done that, and yeah, it's easy to overlook for first runs through scripting with events.
What's happening with the first code is you're /echoing out the initial Text which triggered the #event in the first place. Since #events parse on matches to what you have defined, a "[MQ2] blah blah worn off" meets the requirements to executue it
What this creates is a cyclic loop, causing the event to be triggered over, and over, and over again as events can trigger from any chat medium including MQ2ChatWnd (or MQ2Chat). The /doevents flush "works" but I don't recommend it... I've had it crash one my macros when executed from a Sub Event as you have though I was attempting to do something more complicated. You also, if two events were triggered at really close quarters, could conceivably flush a good event too but it's unlikely giving your basic loop ninja executing /doevents.
As for "corrections", simply don't echo out the full text. Really for macros beyond simple notification you're going to want individual spells being evented as there's a large difference between a snare wearing off and a dot's wearing off from a macro execution / response perspective, but this:
Code: Select all
#event SpellFaded " has worn off."
Sub Main
:Loop
/doevents
/goto :Loop
/return
Sub Event_SpellFaded
/echo SpellFaded
/return
Would work but only give you "SpellFaded" (admittably not what you're attempting to accomplish). To be notified as to *what* specific spell faded, use $arg and a loop to hack out the spell name.
As an illustration, taking Ensnare as an example, the wearing off would be:
"Your Ensnare spell has worn off"
Simply $arg(2,"@Param0") to pick up the word "Ensnare" out of the event text. If you want to get the full spell name, you'll need to repeat args through and build a small text string (or array or whatever) until the word parsed matches "spell" at which point you're done and /echo out the resulting string or array elements.
I'd also recommend putting a delay in your loop too, as a half second or second difference will matter not much at all, and when you add more things (or even #turbo) it'll keep resource utilization down.
G