|
Ranaven Newbie
Joined: 15 Mar 2006 Posts: 9
|
Posted: Tue Feb 23, 2010 3:29 pm
Problem with Triggers. |
I'm trying to setup a trigger from within an alias, making use of a variable in the pattern. Here's the alias:
Code: |
Name: add
#var %1 %1
#var addcheck 1
look %1
#trigger {@%1Desc} {#say Test}
|
The trigger is not created. The desired result? If I type "add Kenneth" I'd like it to create a trigger with the pattern: @KennethDesc.
Also, when I try THIS instead:
Code: |
#var %1 %1
#var addcheck 1
look %1
#trigger {@Character} {#say Test} |
The trigger DOES create, but the pattern text is not the contents of @Character. It is @Character itself. I need Cmud to expand the variable before creating the trigger. The %expand function doesn't help. When I include it, it simply gets added to the trigger pattern.
I'm sure I'm missing something fairly simple. Not a great coder by any means, but I can usually bumble about and mumble through helpfiles and get what I need done. This particular problem has me stumped and it is critical to the script I'm trying to rig together.
Thanks in advance for any help.
Edit: OS is Vista SP 1, Cmud version 3.14 BETA |
|
_________________ Breathe on. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Feb 23, 2010 5:34 pm |
There isn't really an easy way to do what you want. Both variables and function calls are valid within trigger patterns, so you can't just put them in a trigger pattern like that and have it evaluated the way you want. You could probably work around it by concatenating a string with your intended command line, and then performing an #EXEC on it.
What I would suggest is a completely different method. What exactly are you trying to do? I suspect that what you ultimately want is something that watches for character names and highlights them or responds to them. Have you considered using a stringlist? If you have a trigger with a pattern of "@characterlist", and @characterlist was a stringlist like {Boffo|Bill|Bob}, then the trigger would fire on any line containing Boffo, or Bill, or Bob. That way you don't need a dozen different triggers--a single trigger works for all of them, and all you have to do is add or delete names from @characterlist.
If this isn't what you want, tell us what you actually want to do with this code. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Feb 23, 2010 6:38 pm |
Have you tried %pat()? In Zmud, the way to do this would be by adding more % to the variable (ie, %%1). That got really confusing to follow, however, so Zugg gave us %pat(). Not sure it'd apply in this situation, however, since I never had a need for this function.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Feb 23, 2010 9:06 pm |
Actually, I made an error earlier. You need braces around the variable, to make it search for individual members of the stringlist. The pattern for what I suggested should be: {@characterlist}
|
|
|
|
Ranaven Newbie
Joined: 15 Mar 2006 Posts: 9
|
Posted: Wed Feb 24, 2010 11:46 am |
You're partially correct in that it's to do with character recognition. I've considered the stringlist, but getting a stringlist to do what I need is beyond my admittedly meagre abilities with Zscript, or maybe it's just not possible, I dunno. But I'm pretty sure it can be done, just not by me.
The mud I play on has short descs for characters and no names. Often, being an absentminded fellow, I forget the names of characters, even though I know who they are. Also, it's a big stumbling block for newbies to the genre, not seeing a character name on screen.
What I'd LIKE to do, end result is:
Have descriptions and associated character names show up in a window docked to the session window whenever those characters appear IG. So, let us assume that there's a guy who goes by the short description of "An overly obese, bald-headed man", whose name I know to be "Cheeseburger". Cheeseburger shows up, and my child window ought to display something like this:
Code: |
An overly obese, bald-headed man [Cheeseburger] |
So, here's what I tried/thought would work:
1. Create an alias that: adds someone's name to the variable of the same name;toggles my conditional variable (which tells my description capture trigger to capture the requisite text);fires the look command so that text will be retrieved that contains the stuff the trigger will match.
2. Create the trigger which: Captures the desc and saves it to a variable that has the name format of something like "Charname"Desc (KennethDesc if I were adding Kenneth).
3 (The problem) Create a trigger that matches the contents of KennethDesc so that it can send the appropriate #show commands to the child window. I can do this manually, of course, but that sort of defeats the purpose of the script. I'm looking for some way for this trigger to be created as part of the process, either in the alias, or in the capture trigger.
Otherwise, I need to create that trigger manually for every desc I want identified. The reason I couldn't work with stringlists is:
a) I didn't know how exactly to #show a specific string from the stringlist when the trigger pattern is @characterlist for example. If I see Cheeseburger wandering around, how would I get the trigger to print out his desc (which would fire the trigger), out of all the others that @characterlist contains?
b) If I could figure out how to get to the appropriate string in the list, which I'm sure is possible, simply beyond my means, how do I then get the appropriate name pulled from @characternamelist?
You're likely right, I'm going about this the wrong way... and I would welcome any advice anyone might have to offer. A bit stumped myself (not unusual, though). |
|
_________________ Breathe on. |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Wed Feb 24, 2010 1:09 pm |
#EXEC %concat("#TRIGGER {@",%1,"desc} {#SAY Test}") will work. To get the variable to expand, you'll need to execute it like this.
*shrug*
I'm too tired to do anything like show a better way to handle it, though. :P
Charneus |
|
|
|
Ranaven Newbie
Joined: 15 Mar 2006 Posts: 9
|
Posted: Wed Feb 24, 2010 1:37 pm |
charneus wrote: |
#EXEC %concat("#TRIGGER {@",%1,"desc} {#SAY Test}") will work. To get the variable to expand, you'll need to execute it like this.
*shrug*
I'm too tired to do anything like show a better way to handle it, though. :P
Charneus |
Thanks! With this, I can work it. I had a temporary and inelegant workaround that had twenty odd copy and paste triggers ready with the variables varying by a number, and having the names/descs saved to numbered variables automatically. With this, I can get it to work without hassle. |
|
_________________ Breathe on. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Feb 24, 2010 2:28 pm |
Yeah, Charneus has demonstrated the #EXEC method I hinted at but was too tired to work out. Thanks, Charneus!
Since you want to associate a list of short descs with names, you could do it with a database variable, using the variable in the pattern as I described above. If you're curious, I can work out the code, but the #EXEC method should work fine for you.
By the way, having the short descs and names pop up in a separate window is a clever solution. A while back I was pondering ways to handle a similar situation, compounded by the fact that the short descs were not necessarily unique. So I didn't want to simply replace the short desc, or even add the name after the desc in the mud output. A separate window is a good idea. If it scrolls, the most recently seen people will be on the visible portion. |
|
|
|
Ranaven Newbie
Joined: 15 Mar 2006 Posts: 9
|
Posted: Wed Feb 24, 2010 2:58 pm |
Rahab wrote: |
By the way, having the short descs and names pop up in a separate window is a clever solution. A while back I was pondering ways to handle a similar situation, compounded by the fact that the short descs were not necessarily unique. So I didn't want to simply replace the short desc, or even add the name after the desc in the mud output. A separate window is a good idea. If it scrolls, the most recently seen people will be on the visible portion. |
That's exactly what I was thinking, actually. Also, I tried messing around with database variables before I went the current route but (and I don't remember what stumped me exactly - absentminded, as I mentioned) I bombed. :(
But! I can swing it with this. I work like a... well, something. Just keep on pecking till I get it right. Sometimes I hit a rock, like this trigger problem, but thank you all for helping me out. |
|
_________________ Breathe on. |
|
|
|
|
|
|
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
|
|