Why do variables only fire once? And is there a way to make them fire more than once? If not, why not?
variables
Posted by Spudmonkey on Wed 13 Nov 2002 03:09 AM — 12 posts, 35,889 views.
Variables don't fire, they just exist to hold data. Can you describe what you are doing? What do you mean by "variables fire once"?
Here's an example.
"a * * is * from here" would be the string I'm going to match.
%1 and %2 would be the name of a mob, for example "small squid" %3 would be the direction that the mob is, this is using track. So I wold want the trigger to do this:
%3
track '%1 %2'
So say the small squid is to the north, the message I would get would be
"A small squid is north from here"
What I would want that to set off would be:
north
track 'small squid'
Now, I got that to work, but it only works once. I guess evaluate would be a better word than fire. What I'm wondering is, can I make it so that that trigger will continue to track the mob that I am trying to find and kill?
"a * * is * from here" would be the string I'm going to match.
%1 and %2 would be the name of a mob, for example "small squid" %3 would be the direction that the mob is, this is using track. So I wold want the trigger to do this:
%3
track '%1 %2'
So say the small squid is to the north, the message I would get would be
"A small squid is north from here"
What I would want that to set off would be:
north
track 'small squid'
Now, I got that to work, but it only works once. I guess evaluate would be a better word than fire. What I'm wondering is, can I make it so that that trigger will continue to track the mob that I am trying to find and kill?
Ah, I see what you mean. The %1 'variables' are really only for the lifetime of that particular trigger firing, however you can do a couple of things with them.
One is to call a script, then the script can save up to 9 of them in variables (by using setvariable). In your case a simpler method is to use two triggers. One saves %1 as a variable "target" by using "send to variable". The other, matching on the same string, does the initial response. Like this ...
Then you can use "target" in aliases etc. later on, by referring to @target and checking "expand variables". I changed your trigger a bit to use a single wildcard to match on "small squid", because the trigger uses the keyword "is" to tell where the mob name ends.
Here is an example alias "c" that when you type it casts a spell on the current target ...
One is to call a script, then the script can save up to 9 of them in variables (by using setvariable). In your case a simpler method is to use two triggers. One saves %1 as a variable "target" by using "send to variable". The other, matching on the same string, does the initial response. Like this ...
<triggers>
<trigger
custom_colour="2"
enabled="y"
keep_evaluating="y"
match="a * is * from here"
sequence="100"
>
<send>%2
track '%1'</send>
</trigger>
<trigger
enabled="y"
keep_evaluating="y"
match="a * is * from here"
name="target"
send_to="9"
sequence="100"
>
<send>%1</send>
</trigger>
</triggers>
Then you can use "target" in aliases etc. later on, by referring to @target and checking "expand variables". I changed your trigger a bit to use a single wildcard to match on "small squid", because the trigger uses the keyword "is" to tell where the mob name ends.
Here is an example alias "c" that when you type it casts a spell on the current target ...
<aliases>
<alias
match="c"
enabled="y"
expand_variables="y"
>
<send>cast 'fireball' '@target'</send>
</alias>
</aliases>
I get what you are saying for the most part. But can I use @target in another trigger to make the trigger continuous. I know I can do it for the aliases, but is it possible to keep the trigger going. The reason I ask is because in an area of the mud I play, things move around, and I track them, but if it only evaluates it once, then it won't continue to track them, and I'll never move from that room if I don't do it manually. I've tried several things, and none of them have worked yet.
Yes, that is what I am saying. Once @target is set you can keep using it in triggers and aliases.
Can you give an example of what you are trying to do?
Can you give an example of what you are trying to do?
What I'm trying to do is when I go to an area where the mobs move around, and I want to find one, I want to be able to just type 'track <mob>' and have it auto track from there on out. It's really not that big of a deal, I'm just curious to see how it works, and maybe if I can get that to work, I can think of other neato things to do. Anyway, that's what I'm trying to do, if that isn't clear enough tell me and I'll put up an exact example.
You could make an alias that sets the mob name into a variable, but it isn't clear to me how you would auomatically track. Can you give an example of what you expect to see?
<input>track 'small squid'
<string to match>A small squid is north from here.
<send to mud>north
track 'small squid'
<string to match>A small squid is east from here.
<send to mud>east
track 'small squid'
<string to match>A small squid is down from here.
<send to mud>down
track 'small squid'
And on like that until I find the squid, then have another trigger to kill the squid. I hope that makes more sense.
<string to match>A small squid is north from here.
<send to mud>north
track 'small squid'
<string to match>A small squid is east from here.
<send to mud>east
track 'small squid'
<string to match>A small squid is down from here.
<send to mud>down
track 'small squid'
And on like that until I find the squid, then have another trigger to kill the squid. I hope that makes more sense.
There is an interesting post about this sort of thing: Wilderness Walker
However in your case a simpler solution would probably work. You need a couple of aliases "track" and "notrack".
"track <target>" starts tracking
"notrack" stops tracking
Then a trigger to match the message: "A <target> is <direction> from here." ...
Finally a couple of small subs to go into your script file (language VBscript) ...
"track <target>" starts tracking
"notrack" stops tracking
<aliases>
<alias
script="NoTrack"
match="notrack"
enabled="y"
>
</alias>
<alias
script="DoTrack"
match="track *"
enabled="y"
>
</alias>
</aliases>
Then a trigger to match the message: "A <target> is <direction> from here." ...
<triggers>
<trigger
custom_colour="3"
enabled="y"
expand_variables="y"
match="A @target is * from here."
name="tracktrigger"
sequence="100"
>
<send>%1
track '@target'</send>
</trigger>
</triggers>
Finally a couple of small subs to go into your script file (language VBscript) ...
'
' --------- Start tracking ------------
'
sub DoTrack (sName, sLine, wildcards)
'
' remember who we are tracking
'
world.SetVariable "target", wildcards (1)
world.ColourNote "white", "darkblue", "Now tracking " & _
wildcards (1)
'
' ask the MUD where they are
'
world.Send "track '" & wildcards (1) & "'"
'
' enable the track trigger
'
world.EnableTrigger "tracktrigger", vbTrue
end sub
'
' --------- Stop tracking ------------
'
sub NoTrack (sName, sLine, wildcards)
'
' we are not tracking anyone
'
world.SetVariable "target", ""
world.ColourNote "white", "darkblue", "Tracking cancelled"
'
' disable the track trigger
'
world.EnableTrigger "tracktrigger", vbFalse
end sub
Sweet, that works. Thanks a lot.