|
加在shujian.lua或lujing.lua都行。
-- 自定义实现, 执行单个 含#的连续命令, 如 #15n 或者 #15(drop corpse)
-- ---------------------------------------------------------------
function exec_multi(cmd)
if string.find(cmd, "#") and not string.find(cmd, ";") then
if string.find(cmd, "%(") then
local tstr = ""
local _, _, time, c = string.find(cmd, "^#(%d+)%((.+)%)$")
if time then
for i = 1, time do
tstr = tstr .. c .. ";"
end
end
return tstr
else
local tstr = ""
local _, _, time, c = string.find(cmd, "^#(%d+)%s*(.+)$")
if time then
for i = 1, time do
tstr = tstr .. c .. ";"
end
end
return tstr
end
end
end
-- ---------------------------------------------------------------
-- 自定义实现, 处理原mud以及mush常用的表达方式如 ( #15n 或者 #15(drop corpse))
-- ---------------------------------------------------------------
function exec(cmd)
local cmds_str = ""
if string.contain(cmd, ";") then
local cmds = string.split(cmd, ";")
for i = 1, #cmds do
local c = ""
if string.contain(cmds[i], "#") then
c = exec_multi(cmds[i])
else
c = cmds[i]
end
if string.len(c) > 0 then
if string.sub(c, -1) == ";" then
cmds_str = cmds_str .. c
else
cmds_str = cmds_str .. c .. ";"
end
end
end
else
cmds_str = exec_multi(cmd)
end
return cmds_str
end
function tableCopy(T)
T2={}
for k,v in pairs(T) do
T2[k]=v
-- print("T2" .. k .. "= =" .. T2[k])
end
return T2
end
-------------------------
这样在mush里我们就可以输入象#5 n;#2 w,这样连续的命令了。 |
|