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 ➜ General ➜ Capture last direction sent to Mud via keypad to variable

Capture last direction sent to Mud via keypad to variable

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


Posted by Brrant   (1 post)  Bio
Date Wed 10 Dec 2008 03:41 PM (UTC)
Message
Hi,

I need to re-create a simple script I had in zmud for dealing with doors/gates/archways/trapdoors, etc.

When I'm moving via the keypad, (so command history is out) I want to always have the last direction I moved stored in a variable. (This is *not* coming from a speedwalk.)

Then when I trigger on text such as "* is closed", where * is a door/gate/arch/trapdoor I can issue a command to "open varLastDir". If I next get a message saying "* is locked." I can resend that variable to "bash varLastDir".

I'm open to other approaches for this problem, but there are other uses which having last direction stored for is handy, so I'd really like to figure out how to do that.

Thanks!
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #1 on Wed 10 Dec 2008 06:07 PM (UTC)

Amended on Wed 10 Dec 2008 06:08 PM (UTC) by Worstje

Message
Make an alias that sends to script and is a regular expression that looks like: ^(north|south|in|etc|etc)$

In the Send: field, put the following code:

world.SetVariable("direction", "%1")
world.Send("%1")



Now make your alias to bash or whatever with, and simply have it do 'bash @direction'.

P.S.: There's shorter and argumentably simpler ways, but I prefer to do it like this. :)
Top

Posted by Tim Nesmith   (2 posts)  Bio
Date Reply #2 on Wed 19 Aug 2009 11:06 PM (UTC)
Message
is this verified. I tried it and it does not work. I am sure that I am doing something wrong. I am very new to this and have a minimal understanding of any sort of programming. I have to be spoonfed. Sorry.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 19 Aug 2009 11:38 PM (UTC)
Message
Did you make an alias?

Template:what Please help us by showing:
  • A copy of the trigger, alias or timer you were using (see Copying XML)
  • The error message, if any, that you got

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 19 Aug 2009 11:52 PM (UTC)

Amended on Thu 20 Aug 2009 06:14 AM (UTC) by Nick Gammon

Message
Basically you want an alias that captures movements, and saves the direction, like this:


<aliases>
  <alias
   match="^(n|s|e|w|u|d|north|south|east|west|up|down|ne|nw|se|sw)$"
   enabled="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
SetVariable("direction", "%1")
Send("%1")
</send>
  </alias>
</aliases>


This will fire even from the numeric keypad. Now the variable "direction" remembers which way you last went, and the Send sends it to the MUD so you actually go that way.

Now a trigger for the closed door:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   expand_variables="y"
   match="* is closed."
   sequence="100"
  >
  <send>open @direction</send>
  </trigger>
</triggers>


That opens the door in the variable stored in "direction".

Similarly for a locked door:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   expand_variables="y"
   match="* is locked."
   sequence="100"
  >
  <send>unlock @direction</send>
  </trigger>
</triggers>



Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


21,363 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.