I noted that it had a problem with reversing counts greater than 9, so for example 14w gets reversed into 41e. Reversing the numbers again takes care of it.
Besides that I opted to use expandAlias() instead of send(). That way I can use an alias to detect my movement and move the map accordingly when speedwalking.
Code: Select all
walklist = {}
walkdelay = 0
function speedwalktimer()
send(walklist[1])
table.remove(walklist, 1)
if #walklist>0 then
tempTimer(walkdelay, [[speedwalktimer()]])
end
end
function speedwalk(dirString, backwards, delay)
local dirString = dirString:lower()
walklist = {}
walkdelay = delay
local reversedir = {
n = "s",
en = "sw",
e = "w",
es = "nw",
s = "n",
ws = "ne",
w = "e",
wn = "se",
u = "d",
d = "u",
ni = "out",
tuo = "in"
}
if not backwards then
for count, direction in string.gmatch(dirString, "([0-9]*)([neswudio][ewnu]?t?)") do
count = (count == "" and 1 or count)
for i=1, count do
if delay then walklist[#walklist+1] = direction
else expandAlias(direction)
end
end
end
else
local returnpath=dirString:gsub("(%d+)", function(d) return d:reverse() end)
for direction, count in string.gmatch(returnpath:reverse(), "(t?[ewnu]?[neswudio])([0-9]*)") do
count = (count == "" and 1 or count)
for i=1, count do
if delay then walklist[#walklist+1] = reversedir[direction]
else expandAlias(reversedir[direction])
end
end
end
end
if walkdelay then speedwalktimer() end
end
This is my movement alias:
Code: Select all
^(n|ne|e|se|s|sw|w|nw|u|d|up|down|out|o|east|north|northeast|northwest|south|southeast|southwest|west)$
Code: Select all
send(matches[2],false)
I hope that someone will find it useful.
/Chrio