|
bleme1 Newbie
Joined: 14 Jan 2009 Posts: 2
|
Posted: 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? |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: 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. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Wed Jan 14, 2009 7:12 am |
Edit: Sorry it double posted on me. Please ignore this post.
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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}).
|
|
|
|
bleme1 Newbie
Joined: 14 Jan 2009 Posts: 2
|
Posted: 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.
|
|
|
|
|
|