Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 12, 2007 9:41 pm   

Using functions in triggers
 
In another post we were talking about using %concat in a function. What I learned about functions within trigger patterns is that they seem to work if the %function name doesn't look like a wildcard. For example,

%word(...)

looks like a %w wildcard to the trigger pattern parser.

This means that %concat *should* be working. Here is what I just tried in 2.06:
Code:
Name=Zugg
#TRIG {Test%concat(@Name,"s")} {#SHOW fired}
#SHOW TestZuggs -> fired
Name=Chiara
#SHOW TestZuggs -> didnt fire
#SHOW TestChiaras -> DID fire

So this example seemed to work just fine.

Now, as far as handling functions that start with the same letter as a wildcard, what do people think of using the %%function syntax to embed a function within a trigger pattern? I think it might be pretty easy to implement.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Oct 12, 2007 9:50 pm   
 
Oh yeah, in v2.05 you need to enter each line above separately. When a variable was changed in v2.05, Triggers were only updated by a message sent to the main thread, so changing "Name=Chiara" didn't effect the trigger until the entire script was done. So if you enter all the lines as a single command line script, it would fail, but entering each line itself would work. In v2.06 this isn't a problem since triggers are properly expired even in background threads (only buttons and status bar items wait for the main thread)
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Fri Oct 12, 2007 11:42 pm   
 
%%function seems fine to me. Smile I think it's important that this syntax would also work for functions that don't start with the same letter as a wildcard though - for consistency. Cool
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Oct 13, 2007 12:32 am   
 
I am not sure how exactly you are handling it with the regex engine, but I think I would rather prefer %{name of whatever} since this is already a valid syntax. Some examples being %{i} @{%{i}Variable}

I think %{concat("word1","345)} would be better then the doubled percent. Currently 2.05 gives an error on parsing that when it is done with a #SHOW from the command line.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Oct 13, 2007 4:18 am   
 
Actually, it was a lot easier to handle the %% in the parser than to use %{}. Although I'll also try to support that syntax in the future since the fact that it's not already working seems to be a bug.

And yes, it works for any function, regardless of whether they start with the same letter as a wildcard. Let me know how they work in 2.06 (yes, this post probably should be in the Beta forum, sorry)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net