[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Capture last direction sent to Mud via keypad to variable
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

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] Refresh page


Posted by Brrant   (1 post)  [Biography] 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!
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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. :)
[Go to top] top

Posted by Tim Nesmith   (2 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,478 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,478 posts)  [Biography] 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
[Go to top] 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.


4,200 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]