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


Joined: 14 Jan 2009
Posts: 2

PostPosted: Wed Jan 14, 2009 6:45 am   

String list triggers
 
I have a string list variable:
#var hate {bunny|bird|frog}
Whenever I see something in that variable, I want it to trigger:
#act {@hate} {kill @hate}
I have also tried:
#act {@hate} {kill %1}
#act {@hate} {kill $1}
#act {@hate} {kill <@hate>}
#act {@hate} {kill <%1>}

And just about any other thing I can think of, but it either replaces the variable with a blank or it puts in the whole string (bunny|bird|frog). Any ideas to fix it?
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Wed Jan 14, 2009 7:11 am   
 
Code:
<trigger priority="20" regex="true" id="2">
  <pattern>\b(@list)\b</pattern>
  <value>#send {kill %1}</value>
</trigger>


This is a bad idea though. The problem with creating auto kill triggers like this is that any time a word in the list appears in a line of text you'll be sending kill <thing> to the MUD. This could cause problems. What if you are fighting for example monsterA and monsterB, which is also in the list, walks into the room? Now you stop attacking monsterA and start attacking monsterB. Worse yet, what if you put character names in there for player killing? Any time one of them walks by you will start attacking them.

A better approach would be to just print an alert or something that bunny is in the room. Then switch your target manually.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Wed Jan 14, 2009 7:12 am   
 
Edit: Sorry it double posted on me. Please ignore this post.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Jan 14, 2009 7:42 am   
 
If you want to use zScript pattern syntax, you can just do

#act {({@hate})} {kill %1}

See also.
_________________
Rorso's syntax colouriser.

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


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jan 14, 2009 2:16 pm   
 
As an explanation, you need to put parentheses () around the text so that %1 will refer to it: (@hate). If you don't, %1 will be blank. Since @hate is a stringlist, you then need to put braces {} around the variable to expand it, so the trigger will successively try each value: ({hate}).
Reply with quote
bleme1
Newbie


Joined: 14 Jan 2009
Posts: 2

PostPosted: Fri Jan 16, 2009 7:04 am   
 
Thanks for looking out for me oldguy2, but I really simplified my question just so I could re-learn the basics and go from there. My hard drive crashed recently and I am trying to reconstruct scripts that I wrote 10 years ago. Thanks again for the help. It works like a charm.
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