Simple speedwalk reverse

Posted by Bradley on Sat 10 Aug 2002 09:45 AM — 5 posts, 22,191 views.

#0
I've looked about the help files to see if there is a way of simply reversing speedwalking. There is in the mapper but one that could be easily used within on the command line would be nice.

eg the following speedwalk
#n4wes
could be reversed by
##n4wes

the ## simply tells mushclient to reverse the speedwalk so n4wes becoems s4ewn
Australia Forum Administrator #1
You can do it with some command-line scripting, like this:


/world.send world.ReverseSpeedwalk ("#n4wes")


However if that seems a bit tedious, you could make a simple alias (eg. "## *") that did exactly that in a script.
Australia Forum Administrator #2
My earlier answer is a bit incorrect, you need to evaluate the speedwalk as well as reversing it, that would just send the reversed speedwalk to the MUD.

However to make a more general reply, here is a small plugin which will do the trick, with a bit of error detection (it won't send a bad speedwalk string). Just copy everything below the line and paste it into a text file, save it as "reverse_speedwalk.xml" and put into your plugins directory.

Alternatively, download it from:


http://www.mushclient.com/plugins/reverse_speedwalk.xml


(Amended - version 2 - below)




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient 
  [
  <!ENTITY speedwalk_alias "#" > 
  <!ENTITY reverse_speedwalk_alias "##" >   
  <!ENTITY echo_speedwalk "-1" >   
  ]>
<!-- Saved on Saturday, August 10, 2002, 9:00 PM -->
<!-- MuClient version 3.25 -->

<!-- Plugin "reverse_speedwalk" generated by Plugin Wizard -->

<!--
Written for forum posting "Simple speedwalk reverse", see:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=1617

Customise by changing the ENTITY definitions above.

Default is:

#  <speedwalk>   <- do a speedwalk
## <speedwalk>   <- do a reverse speedwalk

You could change that, say if you wanted /w to be a speedwalk, and /r
to be a reverse speedwalk, change the entity above (in the DOCTYPE header)
to:

  <!ENTITY speedwalk_alias "/w" > 
  <!ENTITY reverse_speedwalk_alias "/r" >   

If you do not want the actual speedwalk command echoed in the output window,
change the entity above (in the DOCTYPE header) to:

  <!ENTITY echo_speedwalk "0" >   

-->

<muclient>
<plugin
   name="Reverse_Speedwalk"
   author="Nick Gammon"
   id="bc3d7990489bf6e3fa6d847e"
   language="VBscript"
   purpose="Takes a speedwalk string and sends it, reversed"
   date_written="2002-08-10 20:56:54"
   requires="3.24"
   version="2.0"
   >
<description trim="y">
This provides a simple alias &quot;&reverse_speedwalk_alias;&quot; that sends a reversed
speedwalk to the MUD.

eg.

&reverse_speedwalk_alias; 2s 3e

Would send:
 w
 w
 w
 n
 n

Usage:

&speedwalk_alias; &lt;speedwalk string&gt;     &lt;-- normal speedwalk
&reverse_speedwalk_alias; &lt;speedwalk string&gt;    &lt;-- reverse speedwalk
reverse_speedwalk:help   &lt;-- this help screen

</description>

</plugin>


<!--  Aliases  -->

<aliases>
  <alias
   script="On_Normal_Speedwalk"
   match="&speedwalk_alias; *"
   enabled="y"
  >
  </alias>
  <alias
   script="On_Reverse_Speedwalk"
   match="&reverse_speedwalk_alias; *"
   enabled="y"
  >
  </alias>
</aliases>

<!--  Script  -->


<script>
<![CDATA[

' -----------------------------------
' Normal Speedwalk 
' -----------------------------------

Sub On_Normal_Speedwalk (aliasname, full_line, wildcards)

dim speedwalk
'
'  echo speedwalk on screen
'
]]>
  If &echo_speedwalk; Then
<![CDATA[
  world.ColourNote _
   World.RGBColourToName (World.CustomColourText(World.GetOption("echo_colour"))), _
   World.RGBColourToName (World.CustomColourBackground(World.GetOption("echo_colour"))), _
   wildcards (10)
  End If
'
'  Evaluate it  
'
  
  speedwalk = world.EvaluateSpeedwalk (wildcards (1))
'
'  If first character is an asterisk, there was an error in the speedwalk string
'

  if Left (speedwalk, 1) = "*" then
     world.ColourNote "red", "lightblue", speedwalk
     exit sub
  end if
'
'  Otherwise, send it
'
  world.Send speedwalk

End Sub

' -----------------------------------
' Reverse Speedwalk 
' -----------------------------------

Sub On_Reverse_Speedwalk (aliasname, full_line, wildcards)

dim speedwalk
'
'  echo speedwalk on screen 
'
]]>
  If &echo_speedwalk; Then
<![CDATA[
  world.ColourNote _
   World.RGBColourToName (World.CustomColourText(World.GetOption("echo_colour"))), _
   World.RGBColourToName (World.CustomColourBackground(World.GetOption("echo_colour"))), _
   wildcards (10)
  End If
'
'  Reverse it  
'
  
  speedwalk = world.ReverseSpeedwalk (wildcards (1))
'
'  If first character is an asterisk, there was an error in the speedwalk string
'

  if Left (speedwalk, 1) = "*" then
     world.ColourNote "red", "lightblue", speedwalk
     exit sub
  end if
'
'  Otherwise, evaluate and send it
'
  world.Send world.EvaluateSpeedwalk (speedwalk)

End Sub

' -----------------------------------
' On installation, disable built-in speedwalk 
' -----------------------------------

dim Original_Enable_Speedwalk_Option

Sub OnPluginInstall
   Original_Enable_Speedwalk_Option = _
       world.GetCurrentValue ("enable_speed_walk")
   world.SetOption "enable_speed_walk", 0
   world.DoAfterNote 1, "Plugin " & world.getpluginname & " installed."
   world.DoAfterNote 1, "Version number " & _
       world.getplugininfo (world.getpluginid, 19)
End Sub

' -----------------------------------
' On exit, re-enable built-in speedwalk (if originally enabled)
' -----------------------------------

Sub OnPluginClose
   world.SetOption "enable_speed_walk", Original_Enable_Speedwalk_Option
End Sub

]]>
</script>


<!--  Plugin help  -->

<aliases>
  <alias
   script="OnHelp"
   match="reverse_speedwalk:help"
   enabled="y"
  >
  </alias>
</aliases>

<script>
<![CDATA[
Sub OnHelp (sName, sLine, wildcards)
  World.Note World.GetPluginInfo (World.GetPluginID, 3)
End Sub
]]>
</script> 

</muclient>
Amended on Sat 10 Aug 2002 10:48 PM by Nick Gammon
Australia Forum Administrator #3
My earlier plugin would not work properly as I realised afterwards. The problem is that if you had 'normal' speedwalking enabled, and set to "#" then the 'normal' speedwalk would intercept '##' which would not reach the plugin.

Thus, the solution is to disable built-in speedwalking, and handle both the normal and reverse case in the plugin.

The new version (above) now does that. It has two aliases, "#" and "##" for normal and reverse, respectively.

Also, it is more customisable, by changing the lines


<!ENTITY speedwalk_alias "#" >
<!ENTITY reverse_speedwalk_alias "##" >


(right near the start) you can alter the speedwalk match string to be something else (eg. /w and /r).
#4
Hey thanks for that. Prompt reply too =)