Capture last direction sent to Mud via keypad to variable

Posted by Brrant on Wed 10 Dec 2008 03:41 PM — 5 posts, 22,104 views.

#0
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!
Netherlands #1
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. :)
Amended on Wed 10 Dec 2008 06:08 PM by Worstje
#2
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.
Australia Forum Administrator #3
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
Australia Forum Administrator #4
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.