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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
aseal81
Beginner


Joined: 31 Mar 2009
Posts: 13

PostPosted: Tue Mar 31, 2009 8:25 pm   

Help! Want to create a trigger that create substitutions!
 
#NEWVAR zoneName Tarsis //Another variable within the same class, so it should be accessible, this one will always be manually set.

#ACTION {%e[36m(*)%e[0m$} //This captures the title of every room name on my MUD by looking for a specific ANSI color.
#NEWVAR roomName %1 //Sets the room name in the variable

Trigger works up until there and then breaks down. Next I want it to create substitutions

#ACTION {#SUB {@roomName} {%concat(@roomName, " ", @zoneName)} {Clair Substitutions|@zoneName}


The problem with this is, it takes @roomName as a literal expression instead of the value of the @roomName variable. Is this even possible?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Mar 31, 2009 11:29 pm   
 
Why don't you have it do all that in a single trigger? You wouldn't even have to store the room name in a global variable then.
Reply with quote
aseal81
Beginner


Joined: 31 Mar 2009
Posts: 13

PostPosted: Tue Mar 31, 2009 11:38 pm   
 
It is all a single trigger.
Reply with quote
cazador
Apprentice


Joined: 08 Dec 2005
Posts: 108

PostPosted: Wed Apr 01, 2009 12:22 am   
 
The #actions are creating new triggers. It might be easier for us to see what you paste the xml code
Reply with quote
aseal81
Beginner


Joined: 31 Mar 2009
Posts: 13

PostPosted: Wed Apr 01, 2009 1:05 pm   
 
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <cmud>
- <class name="Clair Substitutions">
- <trigger priority="4240" ansi="true">
<pattern>%e[36m(*)%e[0m$</pattern>
<value>#VAR roomName %1 #VAR currentZone Tarsis #action {@roomName} {#sub %concat(@roomName, " ", @currentZone)} {Clair Substitutions|@currentZone}</value>
</trigger>
</class>
</cmud

Made some changes because it wasn't compiling with #NEWVAR's, not sure why really....
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Apr 01, 2009 3:03 pm   
 
This script has a lot of problems. First, you have all of your commands on a single line, with only a space between them. Separate zscript commands have to be separated by a carriage return or a semicolon. Second of all, the #ACTION command is equivalent to the #TRIGGER command. It is creating a new trigger containing the #SUB command--it is not trying to do the substitution itself. From what you have described, it sounds like you want this code to actually do a substitution. What you are actually doing is creating a separate trigger for every single room.

I am going to assume that what you actually want to do is simply replace the mud text containing the room name with a new line containing both the room name and the zone name. For now, I will use local variables, assuming that you do not need to use the variables @roomName and @currentZone in any other scripts--tell me if that is not correct!
Code:

<trigger priority="4240" ansi="true" id="33">
  <pattern>%e[36m(*)%e[0m$</pattern>
  <value>#local $roomName $currentZone
$roomName = %1
$currentZone = Tarsis
#sub %concat(@roomName, " ", @currentZone, %crlf)</value>
</trigger>

Does this do what you want?
Reply with quote
aseal81
Beginner


Joined: 31 Mar 2009
Posts: 13

PostPosted: Wed Apr 01, 2009 5:19 pm   
 
The breaks were lost when I exported to XML, all that being said, this comes closer to accomplishing what I was attempting to do then my other attempts....
Still having issues with it, but at least it appears to be headed in the right direction....
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Apr 01, 2009 8:16 pm   
 
What are the issues?

You shouldn't have needed to export to xml. On the Package Editor you should see a tab at the bottom of the script window labeled XML. You can simply cut and paste from that XML window into the forum.
Reply with quote
aseal81
Beginner


Joined: 31 Mar 2009
Posts: 13

PostPosted: Thu Apr 02, 2009 2:07 pm   
 
Each substitution should be unique, based on the information pulled from the mud and the zone name that I have entered but the only thing that is created is a generic sub that appears to still point to @roomName and @currentZone.

The idea is for this trigger to create a new substitution automatically for each room, instead what it does is create a generic substitution that doesn't contain any information. Each room should generate a new substitution (realize there would be multiples), let me know if there is a need for further clarification and thanks for taking the time respond, I really appreciate it.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Apr 02, 2009 2:39 pm   
 
Essentially all you want to do is append the current zone to the name of the current room, yes? Using this method is a pretty roundabout way of doing it, especially once you've done it for a lot of rooms. If you use the mapper, and could make a trigger to fire on all room names, it'd be pretty easy to return the name of the current zone and append it to the room name using #sub. Having one trigger will be much better than having hundreds or thousands of them for the same purpose.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
aseal81
Beginner


Joined: 31 Mar 2009
Posts: 13

PostPosted: Thu Apr 02, 2009 2:54 pm   
 
Fang,

I completely agree with you on that count, and for myself, probably will do just that seeing as I've mapped most of the MUD out, but pulling information from the mud and having it create dynamic subs and a few other actions is something I'd very much like to do....
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Apr 02, 2009 3:24 pm   
 
I'm sorry, I made a mistake in the code I posted earlier. The code should be:
Code:

<trigger priority="4240" ansi="true" id="33">
  <pattern>%e[36m(*)%e[0m$</pattern>
  <value>#local $roomName $currentZone
$roomName = %1
$currentZone = Tarsis
#sub %concat($roomName, " ", $currentZone, %crlf)</value>
</trigger>
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Apr 02, 2009 3:27 pm   
 
You probably don't want to be making subs based on triggers, because they will continue trying to make new subs every time that trigger text comes from the mud, even if a sub already exists. Can you come up with a situation where you would actually like to do that? If we had an actual example, we can come up with something.
Reply with quote
aseal81
Beginner


Joined: 31 Mar 2009
Posts: 13

PostPosted: Thu Apr 02, 2009 4:29 pm   
 
Well, the purpose of it is for player killing with a spell called Clairvoyance that; the spell tells you where the opposing player is and having a huge set of substitutions for specific zones would greatly help in finding players in particularly tricky locations. It's not a trigger that is on in all circumstances, more something that is turned on and an area is run through and certain rooms are run to because my MUD has locations that people like to hide in for and after player killing occurs.

Also, using the same principals to create easy highlights {for instance if I could have an alias where i typed addpk <player name> and it'll automatically create all the highlights and pk triggers with that players name without having to manually create triggers for each instance....
Reply with quote
aseal81
Beginner


Joined: 31 Mar 2009
Posts: 13

PostPosted: Thu Apr 02, 2009 4:34 pm   
 
Hmmm new trigger causes an infinite loop and disables itself :/
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Apr 02, 2009 8:38 pm   
 
Having it in an alias is different--that's a fine thing. What I was saying is you wouldn't want to be creating the substitution triggers within a trigger, because every time you entered that room you'd be trying to create a new substitution trigger.

Hm. Bleh, of course it causes an infinite loop. Hm. Try checkmarking the "Stop further processing" on the trigger, see if that fixes the loop. But from your new explanation of what you want, it's clear this won't be sufficient. It sounds like what you really want is to be able to identify what room and zone someone is in based on a Clairvoyance. I suggest that having hundreds or thousands of triggers for this would be rather slow, and not nearly the best solution. What I would do is capture the room name and do a %mapquery() which returns roomids, then run the roomids through %roomzone(), and print the possible zone names with %zonename()
Reply with quote
aseal81
Beginner


Joined: 31 Mar 2009
Posts: 13

PostPosted: Fri Apr 03, 2009 3:03 pm   
 
<alias name="addpk" enabled="false" id="492">
<value>#LOCAL enemy
$enemey = %1
#CO {$enemy} {Blue} {Player Killer HighLights}</value>
</alias>


Ok so here's trying to use the same principals in an Alias, and it does the same thing.

Rather then creating a color sub w/ that players name, it create a a color sub for $enemy :)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Apr 03, 2009 8:44 pm   
 
You misspelled "enemy" as "enemey" once. And, just as with the #sub command, to fix the problem you are reporting, you just need to get rid of the brackets around $enemy.
Code:

<alias name="addpk" enabled="false" id="492">
<value>#LOCAL enemy
$enemy = %1
#CO $enemy {Blue} {Player Killer HighLights}</value>
</alias>

In this case, brackets are treated like quotation marks, making $enemy into a literal string. Get rid of the brackets and it works. I already showed you that for the #sub command.
Reply with quote
aseal81
Beginner


Joined: 31 Mar 2009
Posts: 13

PostPosted: Sun Apr 05, 2009 4:17 pm   
 
Ahhh I misunderstood what you were saying with the brackets earlier, thank you for clarifying a second time.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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