Elysiana2007-01-18 15:45:31
Thanks, that does indeed help!
Laysus2007-01-18 17:27:46
I actually had a lot of trouble getting local vars as arguments to work. Kept saying invalid local variable or something similar. >.<
Unknown2007-01-18 17:38:40
QUOTE(Zarquan @ Jan 18 2007, 04:22 AM) 374654
The expression in your #IF, Daruin, is enclosed in curly brackets instead of parentheses. As already mentioned above, that's what causes your strange results. Enclosing an expression in parentheses causes CMUD to evaluate it to a single value. Also, you should be able to use = or == for equivalence in CMUD or zMUD. There is no implicit variable assignment allowed in an expression as part of a command such as #IF, so both options work for comparing values.
Events are akin to aliases that don't stop on the first match and continue executing all matches. You create one with the #EVENT command and you fire it with the #RAISEEVENT command. You can pass values to the event as arguments. For example, to create a prompt command and have two events (in different classes, so you don't overwrite the first with the second and end up with just one event) that fire, you could try this:
CODE
#REGEX {^(\\d+)h\\, (\\d+)m} {#RAISEEVENT OnPrompt %1 %2} "" {nocr|prompt}
#CLASS ClassOne
#EVENT OnPrompt($health, $mana) {#SAY {Health is $health. Mana is $mana.}}
#CLASS 0
#CLASS ClassTwo
#EVENT OnPrompt {#SAY {Firing second event.}}
#CLASS 0
#CLASS ClassOne
#EVENT OnPrompt($health, $mana) {#SAY {Health is $health. Mana is $mana.}}
#CLASS 0
#CLASS ClassTwo
#EVENT OnPrompt {#SAY {Firing second event.}}
#CLASS 0
You may notice that the second event doesn't care about the arguments. Maybe you have something that fires on a prompt just to disable a class or module, but you don't need the health and mana values. You can omit parameters starting at the end (i.e., you could match health and leave mana out, but you cannot match mana and leave health out, unless you switched the order in which you passed the arguments).
Hope that helps more than confuses!
Hrm, I'm confused. Isn't that esentially the same as:
CODE
#REGEX {^(\\d+)h\\, (\\d+)m} {OnPrompt %1 %2} "" {nocr|prompt}
#CLASS ClassOne
#ALIAS {OnPrompt} {#SAY {Health is %1. Mana is %2.}}
#CLASS 0
#CLASS ClassTwo
#ALIAS OnPrompt {#SAY {Firing second event.}}
#CLASS 0
#CLASS ClassOne
#ALIAS {OnPrompt} {#SAY {Health is %1. Mana is %2.}}
#CLASS 0
#CLASS ClassTwo
#ALIAS OnPrompt {#SAY {Firing second event.}}
#CLASS 0
Also, is it possible to create local variables from a trigger similar to how you might use & in the pattern?
Unknown2007-01-18 17:59:28
The difference, as I mentioned, between events and aliases is that aliases will stop after the first match, where events continue. Your OnPrompt aliases will only give one of the two results, based on your sort order in your settings. My events will both execute. It's a subtle difference, but a very important (and powerful) one to note.
Elysiana2007-01-20 21:45:12
Another question regarding cmud events: Is there a simple way to enable and disable events like you would with triggers? I feel a bit silly for not having figured this one out already, but there doesn't seem to be an option to give an event a name.
Unknown2007-01-21 03:04:26
Put the event(s) in a class folder and toggle the class.