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
xongus
Beginner


Joined: 01 May 2011
Posts: 12

PostPosted: Fri May 20, 2011 11:36 pm   

[3.34] Variable expansion in a trigger
 
This is the trigger pattern:
Code:
^In this room you see:{@friends| }1st giant rat


I've read the documentation and tried also with no luck:
Code:
^In this room you see:{(@friends)| }1st giant rat


@friends is a string list:
Code:
 John | Mike | Brian


Am I not expanding the variable correctly or does it not expand within the {} structure?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sat May 21, 2011 2:01 am   
 
First thing is to make sure that the spacing is correct. I would actually recommend removing the spacing from the stringlist and putting the spacing into the trigger pattern, unless there is a reason to have the spaces in the stringlist. Are any of those spaces actually double spaces?
Reply with quote
xongus
Beginner


Joined: 01 May 2011
Posts: 12

PostPosted: Sat May 21, 2011 6:48 pm   
 
Actually there is a reason since the values in the stringlist can actually be strings. I just gave a simple one word examples. You could imagine someone's name to be a combination of alphanumerics including spaces.

Ultimately I know I can just auto generate triggers for each value of @friends, but I could do this in zmud and I'm hoping in cmud as well without having a trigger for every value.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sat May 21, 2011 9:58 pm   
 
What I meant was the strings at the beginning and the end. Is there a reason to have " John " as a value, instead of "John"? If there is no need to have the leading and trailing spaces inside the stringlist, then it would be easier to have the spaces in the trigger itself. You didn't actually answer my question about whether the spacing in the trigger is actually correct.
Reply with quote
xongus
Beginner


Joined: 01 May 2011
Posts: 12

PostPosted: Sat May 21, 2011 10:02 pm   
 
The spacing is correct. There's the option that sometimes there isn't a @friend, hence the or for just an empty space character. The values of the stringlist are arbitrary since I'm really just having issues with expanding a variable within the {} 'or' structure.

The triggers work fine in zmud and I can just generate triggers for each value of the variable. I'm just trying not to have dozens of triggers active and instead have one. I apologize if I trivialized the values, but they're not whats important. If someone can describe a different way to do this I'd be all ears as well.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sun May 22, 2011 12:56 am   
 
The problem is that you are in fact doing it exactly the way it is supposed to work. I was hoping that the problem was that the trigger was not actually matching because you had incorrect spacing.

Try doing it with just {@friends}. See if it works then (testing whether it works when there is a name there). If it doesn't, then somehow this trigger pattern doesn't match. Cut and paste into this thread a line from the mud that the trigger should work on, so we can see exactly what the pattern is supposed to match.
Reply with quote
xongus
Beginner


Joined: 01 May 2011
Posts: 12

PostPosted: Sun May 22, 2011 2:17 am   
 
Thanks for the advice, but I know the patterns match. I just looped and generated a trigger for each value which do work and is what I'm using now. Its a totally poor way to do this, however the variable expansion as tried above per documentation does not work in cmud.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun May 22, 2011 2:46 am   
 
1)given the stringlist of " John | Mike | Brian "
2)you want to match on the following lines:

In this room you see: John 1st giant rat
In this room you see: Mike 1st giant rat
In this room you see: Brian 1st giant rat

3)and will not see (and therefore do not need to match) these lines:

In this room you see: John Mike Brian 1st giant rat
In this room you see: Mike Brian 1st giant rat
In this room you see: John Brian 1st giant rat
In this room you see: John Mike 1st giant rat

I don't believe you can mix variable stringlists with plain-text stringlists (I don't think this is explained in the documentation), but if you can then the above way is indeed how you would do it and either your pattern doesn't match even though you think it should, you are expecting your pattern to do something entirely outside of what it actually does, or there's something wrong with your trigger.
_________________
EDIT: I didn't like my old signature
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sun May 22, 2011 8:59 pm   
 
If you can't combine a variable stringlist and a text stringlist in a trigger pattern, then the solution would be to put the blank into your variable:
#VAR friends { John | Mike | Brian | }

And then just have {@friends} in your trigger pattern instead of {@friends| }
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