Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Bug reports ➜ variables

variables

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Spudmonkey   (6 posts)  Bio
Date Wed 13 Nov 2002 03:09 AM (UTC)
Message
Why do variables only fire once? And is there a way to make them fire more than once? If not, why not?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 13 Nov 2002 03:11 AM (UTC)
Message
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"?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Spudmonkey   (6 posts)  Bio
Date Reply #2 on Wed 13 Nov 2002 03:52 AM (UTC)
Message
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?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 13 Nov 2002 04:36 AM (UTC)
Message
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 ...


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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Spudmonkey   (6 posts)  Bio
Date Reply #4 on Wed 13 Nov 2002 05:18 AM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #5 on Wed 13 Nov 2002 06:10 AM (UTC)
Message
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?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Spudmonkey   (6 posts)  Bio
Date Reply #6 on Wed 13 Nov 2002 03:59 PM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #7 on Wed 13 Nov 2002 07:56 PM (UTC)
Message
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?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Spudmonkey   (6 posts)  Bio
Date Reply #8 on Wed 13 Nov 2002 08:16 PM (UTC)
Message
<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.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #9 on Wed 13 Nov 2002 09:14 PM (UTC)
Message
There is an interesting post about this sort of thing: Wilderness Walker

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #10 on Wed 13 Nov 2002 09:24 PM (UTC)
Message
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


<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


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Spudmonkey   (6 posts)  Bio
Date Reply #11 on Wed 13 Nov 2002 10:30 PM (UTC)
Message
Sweet, that works. Thanks a lot.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


34,008 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.