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 ➜ Plugins ➜ Aardwolf speedwalk window plugin

Aardwolf speedwalk window plugin

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


Posted by Nick Gammon   Australia  (23,166 posts)  Bio   Forum Administrator
Date Fri 01 Aug 2008 01:10 AM (UTC)
Message
The plugin below is something I wrote to help do speedwalks in Aardwolf. You need to be at recall, and then type "runto" or "runto <location>" (eg. "runto prison").

With no location specified it shows all possible ones, with something specified it filters down to ones with that word in it.

If only one match is found, it immediately starts speedwalking to the desired place.

It has a bit of a bug, if you manually do "speedwalks <somewhere>" then it reloads its cache with the reduced list (sometimes anyway). If that happens type:


refresh runto
speedwalks


That should clear its cache of known speedwalk places, and reload it from the MUD.

To use, copy between the lines and save as Aardwolf_Speedwalks.xml - then use File -> Plugins to load that as a plugin.


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Saturday, June 30, 2007, 10:48  -->
<!-- MuClient version 4.13 -->

<muclient>
<plugin
   name="Aardwolf_Speedwalks"
   author="Nick Gammon"
   id="fa6be25130c2a2c1b43ea361"
   language="Lua"
   purpose="Runs a speedwalk from recall"
   date_written="2008-06-30"
   requires="4.30"
   version="1.0"
   save_state="y"
   >
<description trim="y">
<![CDATA[
Type: runto <location> to speedwalk somewhere

refresh runto --> refresh cache of speedwalks

]]>
</description>

</plugin>

<!--  Triggers  -->

<triggers>

  
 <trigger
   enabled="n"
   match="^Area Name                       Speedwalk *$"
   script="speedwalk_redirect"
   name="start_using"
   sequence="100"
   regexp="y"
  >
  </trigger>
   

 <trigger
   enabled="n"
   match="*"
   script="speedwalk_redirect"
   name="multi_line_speedwalk"
   sequence="10"
  >
  </trigger>
 
</triggers>

<aliases>
  <alias
   name="runto"
   script="runto"
   match="^runto( .+)?$"
   enabled="y"
   sequence="100"
   regexp="y"
  >
  </alias>
  
 <alias
   script="refresh_runto"
   match="^refresh runto$"
   enabled="y"
   sequence="100"
   regexp="y"
  >
  </alias>
    
</aliases>


<!--  Script  -->


<script>
<![CDATA[

speedwalks = {}

require "commas"
require "serialize"  -- needed to serialize table to string
require "checkplugin"

function refresh_runto  (name, line, wildcards)
  EnableTrigger ("start_using", true)  
  Send "speedwalks"
  speedwalks = {}
end -- refresh_runto

function do_the_run (where)
  local old_stack_option = GetOption ("enable_command_stack")
  check (SetOption ("enable_command_stack", 1))
  Execute ("run " .. where)
  check (SetOption ("enable_command_stack", old_stack_option))
end -- do_the_run

function runto (name, line, wildcards)

  local results = {}

  local where = trim (wildcards [1] or "")
  if where == "" then
    for k, v in pairs (speedwalks) do
      table.insert (results, k .. " (" .. v .. ")")
    end -- for
  else
  
    for k, v in pairs (speedwalks) do
      if string.find (k:lower (), where:lower (), 1, true) then
        table.insert (results, k .. " (" .. v .. ")")
      end -- if match
    end -- for
  end -- if
    
  if #results == 0 then
    ColourNote ("red", "", "Speedwalk destination '" .. where .. "' not found.")
    return
  end -- if none found
  
  
  if #results == 1 then
    ColourNote ("yellow", "", "Speedwalking to " .. results [1])
    local run = string.match (results [1], "^(.-) %(")
    do_the_run (speedwalks [run])
    return
  end -- one result
  
  
  local choice = utils.listbox ("Choose area to run to ...", "Speedwalks", results)
  
  if not choice then
    return
  end -- if cancelled
     
  ColourNote ("yellow", "", "Speedwalking to " .. results [choice])
  local run = string.match (results [choice], "^(.-) %(")
  
  do_the_run (speedwalks [run])
  
end -- runto


function process_speedwalk_line (line, styles)
  
  if not string.match (line, "^[A-Za-z]") then
    return
  end -- not a speedwalk line
  
  if not styles [2] then
    return
  end -- not 2 style runs
 
  if styles [1].textcolour ~= 0x00FF00 or   -- lime
     styles [1].backcolour ~= 0x000000 then -- black
    return
  end
  
  local dest = trim (styles [1].text)
  local sw = string.match (trim (styles [2].text), "^run (.+)$")
  
  if not sw then
    return
  end -- not a run command
    
  speedwalks [dest] = sw
  
end -- process_speedwalk_line

-- speedwalk redirector
function speedwalk_redirect (name, line, wildcards, styles)
  EnableTrigger ("multi_line_speedwalk", true)  -- capture subsequent lines

  if name == "start_using" then
    speedwalks = {}  -- empty our table
  elseif string.match (line, "^%{") or
         string.match (line, "^%[") then
    EnableTrigger ("multi_line_speedwalk", false)  -- no more lines to go
    EnableTrigger ("start_using", false)  -- don't capture again
  end -- if
  
  process_speedwalk_line (line, styles)
  
end -- function speedwalk_redirect 

function OnPluginBroadcast (msg, id, name, text)

  -- playing status
  if id == "f5b05e8826711cdb0d141939" then
    playing = text == "y"
    
    if playing then
      started_playing ()
    end -- if playing now
    
  end -- if
     
end  -- OnPluginBroadcast

function OnPluginInstall ()
  assert (loadstring (GetVariable ("speedwalks") or "")) ()

  if GetVariable ("enabled") == "false" then
    ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
    check (EnablePlugin(GetPluginID (), false))
    return
  end -- they didn't enable us last time
  
  OnPluginEnable ()  -- do initialization stuff
  
end -- OnPluginInstall

function OnPluginEnable ()
  assert (GetOption ("enable_triggers") == 1, "Triggers not enabled")
  
  checkplugin ("f5b05e8826711cdb0d141939", "Playing_Detector.xml")
  
  -- see if we are playing at install time
  playing = GetPluginVariable ("f5b05e8826711cdb0d141939", "playing") == "y"
  
  if playing then
    started_playing ()
  end -- if playing now
  
  -- if we are connected when the plugin loads, it must have been reloaded whilst playing
  if IsConnected () then
    OnPluginConnect ()
  end -- if already connected
  
end -- OnPluginEnable

function OnPluginConnect ()
  just_connected = true
end -- function OnPluginConnect

function started_playing ()
  
  -- we already did  it
  if not just_connected then
    return
  end -- if
  
  just_connected = false
  
  -- first time after connect, get speedwalks
  
  if next (speedwalks) == nil then
    DoAfter (3, "speedwalks")  -- grab some speedwalks
  end -- if no speedwalks

end -- started_playing

function OnPluginSaveState ()
  SetVariable ("speedwalks", 
               "speedwalks = " .. serialize.save_simple (speedwalks))

  SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))

end -- function OnPluginSaveState



]]>
</script>
</muclient>

- Nick Gammon

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

Posted by Fiendish   USA  (2,551 posts)  Bio   Global Moderator
Date Reply #1 on Fri 01 Aug 2008 01:13 AM (UTC)

Amended on Fri 01 Aug 2008 01:16 AM (UTC) by Fiendish

Message
This will be built in mudside at next reboot. ^^;
There's still going to be some utility for overriding mud speedwalks using the same mechanism, though.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Pokkie   (11 posts)  Bio
Date Reply #2 on Tue 27 Oct 2009 06:17 AM (UTC)
Message
Why do you need to be at recall for this script to work?

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.


16,878 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.