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
ArjenJ
Wanderer


Joined: 30 Jan 2006
Posts: 66

PostPosted: Wed Jun 18, 2008 9:14 pm   

[2.27] Triggering of stringlists
 
In previous versions (2.18 and before.... and in zMud) I was able to have triggerlines like: {@enemies}

@enemies is a stringlist containing the names of my enemies and the trigger does nothing more than #CW RED.

Since I updated to 2.27 this no longer works. Actually it is not only that it doesn't work, whenever one of these triggers should fire Cmud freezes and all I can do is terminate Cmud by using the taskmanager of Windows Vista.

How should I fix this?
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Jun 18, 2008 9:17 pm   
 
You could try {%%string(@enemies)} Although you shouldn't have to, your pattern should work I think.
Reply with quote
Nayuko
Novice


Joined: 17 Jun 2008
Posts: 41

PostPosted: Wed Jun 18, 2008 9:53 pm   
 
Hah, I've got the same problem. Even with %%string doesn't work. I've just seen it. Maybe it is a cause my script doesn't work.

N.
Reply with quote
ArjenJ
Wanderer


Joined: 30 Jan 2006
Posts: 66

PostPosted: Wed Jun 18, 2008 9:54 pm   
 
Ok that worked fine... now the next step. When @getenemies is switched on I want to send the following command to my mud: enemy [name] In which [name] is replaced by the enemyname that fired the trigger.

This is my code right now:
Code:

<trigger priority="36240" id="3624">
  <pattern>{%%string(@enemies)}</pattern>
  <value>#CW RED
#IF (@getenemies) {enemy %1}</value>
</trigger>


It fires correctly but when it does it turns out that it does not capture the enemyname in %1, and it sends only "enemy " to my mud.
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Jun 18, 2008 9:57 pm   
 
Pattern would then be this ({%%string(@enemies)})

But that would create a trigger loop I believe. You will need to find a better way to display the enemy name. One way to do it is to make your trigger this...

Code:

#TRIGGER { ({%%string(@enemies)}) } {#CW Red
#IF @getenemies {#ECHO Enemy ~{%1~}}}


This would Echo something like...

Enemy {Toxic}

to your screen assuming I was an enemy, and keep from refiring the trigger due to the spaces.
Reply with quote
ArjenJ
Wanderer


Joined: 30 Jan 2006
Posts: 66

PostPosted: Wed Jun 18, 2008 10:02 pm   
 
Yep worked again... now the next step: sometimes there are several enemy names in one incomming line. In these cases my trigger now does color all the enemies red correctly but it somehow only sends the "enemy [name]" command once. Any idea how to fix this? I want it to send the command for every enemy name that comes by, no matter how many are in one line.

Ow and about the trigger loop... I know, yes it does. But that's why i have that @getenemies variable switched on only for very short periods. To break the loop at the moment that variable is set to 0 again. Ugly as hell I know... but still it worked fine before.


Last edited by ArjenJ on Wed Jun 18, 2008 10:04 pm; edited 1 time in total
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Jun 18, 2008 10:03 pm   
 
You might even try something like

#TRIGGER {{^|" "}({%%string(@enemies)}){$|" "}}

That would compensate for the fact that the name might start or end the line and therefore not have a space.
Reply with quote
ArjenJ
Wanderer


Joined: 30 Jan 2006
Posts: 66

PostPosted: Wed Jun 18, 2008 10:07 pm   
 
Toxic wrote:
You might even try something like
#TRIGGER {{^|" "}({%%string(@enemies)}){$|" "}}

I also thought about that but in my mud there are many other things that can be right before or after the name.
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Jun 18, 2008 10:08 pm   
 
The answer to the last step there is probably a trigger option, of which Im not sure because I dont have cmud on me right now, possibly someone else can help... And if you will switch your trigger to the above pattern and encapsulate your Enemy Toxic with something other than spaces, it will stop trigger loops no matter what.
Reply with quote
ArjenJ
Wanderer


Joined: 30 Jan 2006
Posts: 66

PostPosted: Wed Jun 18, 2008 10:16 pm   
 
You're great! There turns out te be a trigger option indeed, called: "repeat within line" which fixed my last problem. My trigger is working perfectly now. Thanks for the help. Very Happy
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Jun 18, 2008 10:33 pm   
 
Sigh....

OK, while I'm glad you got it working, there was some bad advice in this thread that I want to point out for future readers.

You should NOT need to use %%string unless your @enemies string list contains wildcards that you want used in your trigger. Since you didn't show us what is in your @enemies list, then I can't really say for sure.

But please do not tell people to just use %%string when they don't need to. Using {@enemies} in a trigger pattern is still the correct way to use a string list in a trigger pattern. Wild cards in a {} pattern were only recently added as a feature, so very few people should have wildcards in their string lists.

The problems with using {%%string(@enemies)} instead of just {@enemies} are 1) it is much harder to read and will just start confusing people, and 2) using %%string is slower, and 3) if an element in the string list uses any special characters (like % or *), then they will be interpreted as pattern wildcard characters, which probably isn't the original intent of the user.

ONLY use %%string is you really know what you are doing regarding any possible wildcard characters in your string list.

Next, to match the beginning of the line or a word boundary, you don't need to use {^|" "} (which I'm not sure will even work). Use the %b wildcard character to match a word "boundary". The %b ensures that you are either at the beginning of the string, or at the beginning of a word. (Note that %b is the same as %q but the %b is easier to remember because its the same as the regular expression \b for matching a boundary)

Back to the original poster's problem: If just using {@enemies} is causing a hang, check your string list to see if it contains a blank entry. In 2.27 that can cause it to hang. In 2.28 it won't cause a hang, but it will allow {@enemies} to match the null-string, which might not be what you want. In general, make sure your string list doesn't contain null values unless you are sure you know what you are doing with that.

If your @enemies doesn't contain any null value and still causes a crash, please post the full XML of your @enemies variable within [CODE] tags in this forum. Just go into the settings editor and right-click on your @enemies variable in the tree on the left and select Copy in the popup menu. Then paste the result into CODE tags in this forum post.
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Thu Jun 19, 2008 12:32 am   
 
Well. I apologize for posting misinformation. But I did state in the very beginning that {@enemies} should work. I was simply stating ideas on how it might work. So happens it worked, but you are right from the sound of it he has a %null value in the string. I had initially forgotten about this bug. After further testing, your correct that {^|" "} doesn't seem to be working, but I did state at least once that I didn't have cmud in front of me to test any of this.

ArjenJ: Another thing that might help you that I had forgotten about is the #PRINT command, it should allow you to #PRINT Enemy %1 without causing a trigger loop, or at least this is how I interpret the command, I havn't actually used it yet. This is unless of course you need to trigger off of Enemy %1 for some reason.

Hope this helps.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Thu Jun 19, 2008 11:05 am   
 
The other bit of bad advice was saying that you should use "enemy {name}" to avoid trigger loops. ArjenJ is trying to send a command to the game to declare the person officially an enemy, so using the brackets will mess that up. It's not just an echo. I believe that unchecking the Trigger on Trigger option should do the trick instead, or you could use the #SENDRAW command to get the enemy command through without it triggering anything.

To avoid matching on the wrong things, in general, with a trigger like this, I'd recommend checking the Case Sensitive option (and making sure all names are in proper case in your string list) and putting %q at the start and end of the pattern to only match on the whole word. If you then have the enemy command send all lower case names, you won't inadvertently start a trigger loop!
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Jun 19, 2008 11:35 am   
 
A pattern trigger shouldn't be firing on commands anyway, regardless of whether you send it plaintext or with #send or #sendraw. The trouble probably comes when the MUD returns "XXXX is now your enemy." or whatever. You might want to add a negative lookahead to the trigger to handle that.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Thu Jun 19, 2008 4:29 pm   
 
True. It seems a trigger like this could just be a plain old fashioned bad idea. Heh.
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