CUSTOM EVENTS CHANGE COMING

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

Moderator: MacroQuest Developers

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

CUSTOM EVENTS CHANGE COMING

Post by Lax » Sat May 08, 2004 1:12 am

Fair warning, a better system for custom events is coming. chat/timer events work the same way, but custom events using #event will be slightly different.

The difference will be....
parsing

For example... Genbot uses this event

Code: Select all

#Event SelfEcho "[MQ2] Genbot "
However, in the new system it will not work without a slight modification!
The new system requires that you use the entire line of chat. BUT allows for making sections of the line a parameter.

Here is what the change will make this event look like:

Code: Select all

#Event SelfEcho "[MQ2] Genbot #1#"
The #1# in the middle of the match text is what you use to indicate "this part of the message should be given to me in a parameter". The parser will do its best to get you the portion you're asking for if the event matches. The number between the pound signs says what parameter number you want this to be in your Sub Event_Whatever. The first parameter in the sub will be the entire line itself... 1 starts AFTER that. e.g. this event could look like this:

Code: Select all

Sub Event_SelfEcho(string Line, string Command)
Because this system lets you pick the parameter number of any portion of the message, some parameters might not get made (e.g. wont be ${Defined}... it's up to you to make sure you get the ones you need defined.
Also, if you need to SKIP a portion of the text (dont care about it, just need to ignore part of the text that might not match, whatever), you can use #*#.

Imagine this is the text that matches the event text:
"[MQ2] Genbot THIS IS MY COMMAND"
The two parameters are:
Line=[MQ2] Genbot THIS IS MY COMMAND
Command=THIS IS MY COMMAND

The system also allows you to grab a MQ2Data value like this:

Code: Select all

#Event SelfEcho "[MQ2] Genbot |${Me}| #1#"
The system itself has no idea that MQ2Data even exists, and is just looking for the | or #. MQ2 makes it parse what's inside the || as MQ2Data. So, this event would only hit when, if ${Me} is currently "Lax", the message starts like..
"[MQ2] Genbot Lax whatever"
Note that the MQ2Data is not immediately parsed when the event is made, it gets parsed when the system checks to see if the event is a match.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

dok
a ghoul
a ghoul
Posts: 127
Joined: Mon Mar 15, 2004 3:38 pm

Post by dok » Sat May 08, 2004 2:00 am

so, with trying to pass 2 paramaters, it'd be something like this?

full line:
You have been given permission to drag xxxx's corpse in yyyy.

#Event Consented "You have been given permission to drag #1#'s corpse in #2#."

Sub Event_Consented(string Line, string Player, string Zone)


Also, if we dont specify #1# in the line, will the event still work like it has been for events we really dont care about a parameter?

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Sat May 08, 2004 2:06 am

Yes your consent event is correct.

To answer your second question.. As mentioned, you must use up the entire chat line one way or another. If you dont care about part of it use #*#...
example:
#Event SomeEvent "#*#some phrase#*#"

This will find any text with "some phrase" in it, and the only parameter given to the sub will be the line itself.

If you use:
#Event SomeEvent "some phrase"
This will ONLY find a match if that is the ENTIRE line..
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

dok
a ghoul
a ghoul
Posts: 127
Joined: Mon Mar 15, 2004 3:38 pm

Post by dok » Sat May 08, 2004 2:10 am

Also, another question.

With the |${var}|, would that mean we could basically make a totally dynamic event?

ie.
#event DynEvent "|${eventText}|"

/declare eventText string outer [MQ2] Genbot1 #1#
/doevents
/varset eventText [MQ2] Genbot2 #1#
/doevents

Sub Event_DynEvent(string Line, string Command)
/echo ${Command}
/return


Bad example, but if so, basically would allow us to assign events inside of a macro as long as the event is declared with a variable name as the trigger, right?


Anyway, seems like its going to be a pretty cool change.

User avatar
wilso132
Contributing Member
Contributing Member
Posts: 106
Joined: Thu Oct 17, 2002 11:53 am

Post by wilso132 » Sat May 08, 2004 5:51 am

This change is going to be such a timesaver, plus I hate searching for substrings.

Thanks Lax :D

LordGiddion
a snow griffon
a snow griffon
Posts: 352
Joined: Sat Sep 13, 2003 6:12 pm
Contact:

Post by LordGiddion » Sat May 08, 2004 8:06 am

I'm gonna make an assumption but I'm gonna explicted ask it so that it's covered for everyone else as well, Converting old events:
if the old and busted code is

Code: Select all

#event orchit "an orc hits you"
and the actual event is "an orc hits you for 50pt of damage"

then the new and hotness code needs to be

Code: Select all

#event orchit "an orc hits you#*#"
and because the text is expected at the begining of the line then

Code: Select all

#event orchit "#*#an orc hits you #*#"
just won't work.
Cheesey example but first thing I thought of and figured it was best to field some of the questions from the start

Pheph
a hill giant
a hill giant
Posts: 196
Joined: Thu Oct 09, 2003 8:15 pm

Post by Pheph » Sat May 08, 2004 9:15 am

Unless #*# implies one or more characters, it would work with your example.

Unless I'm mistaken Lax said it matched anything which leads me to believe it would match 0 chars too.

But I guess only Lax can tell us which is which :)

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Sat May 08, 2004 9:38 am

Yes, #*# can match 0 characters.

Code: Select all

#event orchit "#*#an orc hits you #*#" 
will match ANY line with "an orc hits you " substring in it, including at the beginning.

Consequently, if you have any defined like so:

Code: Select all

#event orchit "an orc hits you #1##2#"
where two of your parameters come immediately after each other, with nothing separating, the parser can't possibly tell what you wanted in #1# in this instance. #1# will be empty, and #2# will contain the rest of the line.

dok: You could make an *almost* completely dynamic event. Anything inside the || must match verbatim (other than case sensitivity; this is not case sensitive). You cannot have #x# inside your || and expect it to retrieve a parameter (sorry). You can make it dynamic and then parse the parameter yourself though :)

You COULD do something like this:
#event DynEvent "|${EventPrefix}| #1#"
and set the EventPrefix to "[MQ2] Genbot2"
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

eqjoe
a grimling bloodguard
a grimling bloodguard
Posts: 984
Joined: Sat Sep 28, 2002 12:26 pm

Post by eqjoe » Sat May 08, 2004 12:27 pm

This change is exactly what I need to solve a problem that I have with one of my afk macros :)

Sweet.

-j

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

Post by ml2517 » Sat May 08, 2004 1:08 pm

... Jeez at least *try* to keep the afk comments to yourself.

Skye
a lesser mummy
a lesser mummy
Posts: 33
Joined: Thu Jan 08, 2004 10:17 pm

Post by Skye » Sat May 08, 2004 2:07 pm

This is perfect - I can really consolidate much of my buff wearing off code (guess which class I like to play) and make a more dynamic handler with this addition.

Of course, I would prefer standard regexp formats - and well, I like the perl interface too - but then again I'm wacked that way (liking to keep to standards). But hey, I'm not doing the work so I'm happy to learn whatever method is provided :lol:

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Sat May 08, 2004 2:31 pm

We could have some sort of regex command to process a given line, but the above system is a lot easier to use, particularly for people who dont even know what regex is (which is most mq users). i dont get the "liking to keep to standards" comment though.. perl/regex are hardly "standard" ;)
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

eqjoe
a grimling bloodguard
a grimling bloodguard
Posts: 984
Joined: Sat Sep 28, 2002 12:26 pm

Post by eqjoe » Sat May 08, 2004 3:13 pm

Is it possable to trigger on error events? For example:

Code: Select all

#event NoID "There are no spawns matching:(0-100) NCP: ID:#1# "
This way I can capture the spawn ID in this error.

-j

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Sat May 08, 2004 3:25 pm

yes.

I've moved the event handling to WriteChatColor (these events were previously only handled in MQ2ChatWnd, and not in MQ2Chat or MQ2Telnet) so it will check MQ2 text.
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

eqjoe
a grimling bloodguard
a grimling bloodguard
Posts: 984
Joined: Sat Sep 28, 2002 12:26 pm

Post by eqjoe » Sat May 08, 2004 3:51 pm

Lax wrote:yes.

I've moved the event handling to WriteChatColor (these events were previously only handled in MQ2ChatWnd, and not in MQ2Chat or MQ2Telnet) so it will check MQ2 text.
Awesome... I have been using a work around but it requires that I clear my target, target by ID, then check my target. If no target then remove from my active mob array. Being able to do this with an event will no longer require me to loose my current target (because if I do a /target ID 123 and it does not exist my target will not change) and is much more efficient solution.

Thanks,
-j