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
morpheus888dream
Newbie


Joined: 20 Aug 2009
Posts: 5

PostPosted: Wed Sep 02, 2009 3:10 am   

Variable defined as part of trigger text received?
 
I apologize if this has been asked before (I see lots of specific trigger and variable posts, but not sure one that combines some of these elements).

What I am looking to do is define a variable based on a piece of the trigger text received. For example, if I want to start striking my opponents in a specific location, I type:

strike {head}

At which point, the MUD returns:

You will now attempt to strike at your opponent's {head}.

I want the above message to be a trigger and the word head is what I want to become the variable, so that I can output:

will my familiar to strike {head}

The basic idea is that as I change the body location I am striking, I will automatically will my familiar to do the same, mimicking my decisions without me having to write a million triggers for the various body locations I can strike.

Thanks in advance!

p.s. I used the french brackets to point out that this word can change as I choose to strike body, or strike chest, etc.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed Sep 02, 2009 5:41 am   
 
#TRIGGER {You will now attempt to strike at your opponent's (%w).} {will my familiar to strike %1}

That's assuming that it's always going to be just one word. If it's not, then you'll need to do something like:

#REGEX {You will now attempt to strike at your opponent's ((?:\w+ )?\w+)} {#SAY will familiar to strike %1}

Keep in mind that if the brackets are in there, you'll have to escape them. First example, use ~{ and ~} to escape them. Second example, use \{ and \} to escape.

Charneus
Reply with quote
morpheus888dream
Newbie


Joined: 20 Aug 2009
Posts: 5

PostPosted: Wed Sep 02, 2009 12:56 pm   
 
Good to know thank you, the brackets are not part of it, just wanted to point out the piece the text that will actually be dynamic. Much appreciated!
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Sep 03, 2009 1:14 pm   
 
If you want to keep the value for later use you can do something like

bodypart=%1

instead of "will my familiar to strike", and then you can use @bodypart to give you the value anywhere you might need it.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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