Make it compatible with zmud / cmud dirs

Posted by Foldar on Sun 23 Jan 2022 12:41 AM — 2 posts, 10,862 views.

#0
zMUD: #9 w;sw;#4 w;s;sw;w;w;open s;s;s;sw;s;window
MUSHClient: #9w (sw) 4w s (sw) 2w (open s) 2s (sw) s (window)

Many people use zmud if they give me dirs it is mostly in zmud format. would be nice if i could paste it in mushclient
It is a whole lot of typing to adjust it.
Amended on Sun 23 Jan 2022 01:07 AM by Foldar
Australia Forum Administrator #1
Is there really a # in the middle like that? As in #4?

You can make an alias with a bit of scripting to convert them. For example:


<aliases>
  <alias
   match="#*"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

-- extract out each direction
local directions = utils.split ("%1", ";")

local t = { } -- for converted results

for k, v in ipairs (directions) do

  count, remainder = string.match (Trim (v), "^(%d+)%s*(.+)$")

  if count then
    directions = remainder
  else
    count = ""
    remainder = v
  end -- if

  remainder = Trim (remainder) -- remove spaces

  if #remainder &gt; 1 then
    remainder = "(" .. remainder .. ")"
  end -- if more than one letter


  table.insert (t, count .. remainder)

end -- for each direction

Send (EvaluateSpeedwalk (table.concat (t, "")))

</send>
  </alias>
</aliases>


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


Turn off speedwalking in the Input configuration -> Commands, and let the alias do it instead. I haven't allowed for the "#" in the middle as I thought that might just be a typo.

If it isn't you can get rid of it, eg.


remainder = string.gsub (remainder, "#", '')


After the line with "remove spaces" on it.