|
Aeri Newbie
Joined: 25 Sep 2006 Posts: 8
|
Posted: Mon Sep 25, 2006 4:16 pm
Help please. |
Hey everyone. I have just began to play around with zMUD, and I am falling in love with it. I am running into a jam right now, however.
When something engages me I get an emit that looks like something like this:
An enormous illusionary grublin engages Aeri.
The critter in question will always have two words before its attacking word. Like a small muscular grublin. The problem I am running into is trying to capture the grublin into an alias so I can use triggers for attacking. Here is what I did to try to capture it. I know it is probably horribly wrong, but I'm trying!
Trigger: %s{engages}%s{@VMychar}
Value:
critter_name {%1}
attack @VCritter
do_set_tick
critter_name will store the name in @VCritter, and do_set_tick is my way of waiting for the RT to be over.
Any help would be great. Thanks! |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Mon Sep 25, 2006 6:01 pm |
Not sure what you mean by attacking word, but if you mean that you can attack it with the word illusionary or muscular, then try this:
Trigger: %w %w (%w) %* {@VMychar}
Value:
critter_name {%1}
attack @VCritter
do_set_tick
I think this would work. I only assume that it's on illusionary or muscular since you said 2 words before.
illusionary and muscular are the 3rd words. |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Mon Sep 25, 2006 6:09 pm |
Trigger: (%w) engages Aeri.$
Value:
#var VCritter {%1}
attack @VCritter
do_set_tick
There are a few things to note about this. I've assumed there is only one space between the words hence no use of %s to match on multiple white space. There is no point in passing the critter name to an alias to set the variable for it unless the alias does a few other things besides just setting the variable so I've set it directly in the trigger actions. I have hard coded your character name into the trigger and assumed that the pattern has a carriage return after your character name, hence the $ anchor. If you want to put in the character name in such a way that it can be used for another of your characters then you can use the built in function %char unless of course you have already developed a lot of other aliases that already use your VMychar variable.
Trigger: (%w) engages %char.$ --- Using the built in %char variable with an end of line anchor
Trigger: (%w) engages %char --- Using the built in %char variable without an anchor
Trigger: (%w) engages @VMychar.$ --- Using your already created variable for your character and an end of line anchor
Trigger: (%w) engages @VMychar --- Using your already created variable for your character without an anchor
With the patterns for the ones without the end of line anchor I've also not included the fullstop as there won't be much of a speed increase with it, there should be a speed increase with the anchor as it knows to only check from the end of the line and in that case the fullstop is needed. |
|
_________________ Taz :) |
|
|
|
Aeri Newbie
Joined: 25 Sep 2006 Posts: 8
|
Posted: Tue Sep 26, 2006 5:51 am |
Awesome.. I get what you are saying about the %s. Was a lame mistake. One more question. I get it to capture "grublin" but how would I go about capturing all three words of the critter?
Thanks guys! That was some great advice that will help me improve all my scripts. |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Tue Sep 26, 2006 12:21 pm |
Code: |
#TRIGGER {(%w %w %w) engages %char.$} {#var VCritter {%1}} |
|
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Tue Sep 26, 2006 12:21 pm |
so, ya want to capture "enormous illusionary grublin", but attack on "grublin"?
I'm sure there's a better way, damned if I can think of one except for this:
Make 2 triggers.
1) Taz'
Trigger: (%w) engages Aeri.$
2) and This
Trigger: {An|A} (%*) engages Aeri.$
The 2nd one should be the capture. |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Tue Sep 26, 2006 12:23 pm |
Don't use %*, ever. It's bad, bad, bad, bad, bad. Just use * instead.
|
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Tue Sep 26, 2006 3:21 pm |
I would use something like #TRIGGER {(*) engages Aeri.$} {#VAR VCritter=%word("%1",%numwords("%1"));Rest of Code here}
This will take the whole string and return the last word.
I.E "The Damn Critter" will store Critter in VCritter and "A Silly Grublin" would become "grublin"
Zmud has a lot of powerful %functions to manipulate strings and variables. |
|
|
|
Aeri Newbie
Joined: 25 Sep 2006 Posts: 8
|
Posted: Tue Sep 26, 2006 4:29 pm |
This is great guys! The script works fine, and I was able to incorporate the hunting script in with ease. Thanks!
|
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Tue Sep 26, 2006 7:14 pm |
Larkin, Don't use (%*) but use (*)? Mind if I ask the difference? I've used (%*) in a few of my scripts and have yet to run into a problem.
nexela, *drool* Question did you mean to use #var or #func? never been able to figure out when to use which for what. Even after all that you and I went thru with that roster script of mine with the #func's. |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Sep 27, 2006 3:40 am |
Quote: |
Larkin, Don't use (%*) but use (*)? Mind if I ask the difference? I've used (%*) in a few of my scripts and have yet to run into a problem.
|
* and %* are very similar, in that they will match letters, numbers, symbols, and whitespace. This by itself can be a bad thing, as you might match the wrong line and thus gain invalid data. This bad data could cause your script to hang, and that in turn could cause bad things to happen to your character (ie, if you suddenly stopped fighting in combat, you'd probably die).
The truly dangerous aspect of %* is that it matches ANY symbolic character, including the symbols representing the ZMud special characters. These special characters remain active within the script, making it possible for other people to insert commands and scripts of their own into your settings file. Guess how helpful those are.
Now, all of that said, * and %* are not at all dangerous if you aren't using parentheses and working with the stored data. Without that, there's no opportunity for mischief to be had. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Wed Sep 27, 2006 11:18 am |
Thank you, Matt, for explaining more elegantly the point I was trying to make and saving me the time of looking it up. :)
|
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Wed Sep 27, 2006 7:00 pm |
:runs off to remove the (%*)'s and replace them with (*)'s |
|
|
|
|
|