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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
only85
Beginner


Joined: 17 Jul 2002
Posts: 11
Location: USA

PostPosted: Wed Jul 17, 2002 6:59 pm   

Trigger/Variable help :)
 
ok, I have need of a trigger and I can't figure out how to make it work
I need 4 different variables in the trigger

3. 75 tons Musiks from Venus to Titan -

That is an example of the text I recieve, need to recieve that, and put the 3 into a variable, Musiks, Venus, and Titan..
For later use
and I"m not sure how to do it :)

Any help would be appriciated..
Reply with quote
Arthaey
Beginner


Joined: 13 Apr 2001
Posts: 15
Location: USA

PostPosted: Wed Jul 17, 2002 7:35 pm   
 
Word of caution: I'm still using v5.55. I think the trigger should work as is, but if not then holler and somebody familiar with v6.16 will probably correct the differences.

Anyhow, here's what the trigger would be:

#TR {&%d{Tons} tons &%a{Item} from &%a{Giver} to &%a{Receiver}} {}


If you're more comfortable adding triggers through the Editor, then type this into the Pattern field:

&%d{Tons} tons &%a{Item} from &%a{Giver} to &%a{Receiver}


The & tells zMud that you're storing something to a variable named with whatever is between the braces { }. The %d means that the trigger will only fire if the text is numerical -- digits. The %a means only letters will work -- alpha.

Thus, this trigger will store the number of tons to the variable @Tons, the item being transferred as @Item, the person giving the tons of stuff as @Giver, and the receiver as, well, @Receiver. There isn't anything in the Commands field because you didn't say you wanted to do anything with the variables at this time.

This assumes that the people's titles aren't present in the text you receive, because otherwise this won't work.

Good luck!

--
Arthaey
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Jul 17, 2002 8:47 pm   
 
Another way of doing this is to assign the variables in the command field.
#TR {(%d). (%d) tons (*) from (%w) to (%w)} {#VAR number %1;#VAR tons %2; #VAR item {%3};#VAR origin %4;#VAR destination %5}

Anything in parentheses gets saved to the temporary variables %1, %2, etc. %d is the wildcard for numbers. %w is letters only (%a is both letters and numbers). * is the wildcard for letters, numbers, and spaces (for things that might have more than one word). The full list of wildcards can be found in the helpfile under "patterns". Since I used * as the third entry, I've enclosed %3 in braces in case it has more than one word.

You said you wanted to put the 3 in a variable but the 75 seems more likely.

This is for command line entry. If you want to use the editor, the blue part goes in the Pattern field and the green part goes in the Value field.

LightBulb
Senior Member
Reply with quote
Arthaey
Beginner


Joined: 13 Apr 2001
Posts: 15
Location: USA

PostPosted: Thu Jul 18, 2002 4:03 am   
 
I know about the %1 variables, and for when I only want to use the variable for one alias/trigger, I do use them. Is there any other advantage to capturing the variable values by your method rather than mine? Unless the zMud code runs faster, I don't see a real difference.

--
Arthaey
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jul 18, 2002 4:57 am   
 
For instances when the information does not need to used elsewhere the %xx have the advantage of automatically disposing. zMud should also process them faster as they are all replaced at once before the script is passed to the parser. The speed gain would be negligible though.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Jul 18, 2002 5:15 am   
 
The only advantage of the method I suggested is that I find it easier to tell what it's doing and less prone to typo's. Others may find your method easier.

LightBulb
Senior Member
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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