找回密码
 注册
搜索
查看: 330|回复: 5

自定义实现象zmud的执行单个 含#的连续命令

[复制链接]
门派:天龙寺
发表于 2022-6-7 14:11:35 | 显示全部楼层 |阅读模式
加在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,这样连续的命令了。
门派:桃花岛
发表于 2022-6-7 22:25:24 | 显示全部楼层
这个不错啊,又找回一点儿过去的感觉。
门派:武当派
发表于 2022-6-8 17:43:59 | 显示全部楼层
这个东东不错哦,顶一下
门派:古墓派
发表于 2022-6-8 20:52:11 | 显示全部楼层
这个好    这真的是好东西
mush和mud结合起来一起嗨
门派:昆仑派
发表于 2022-6-8 22:14:42 | 显示全部楼层
这个好用 总算不用一次次输入了
门派:昆仑派
发表于 2022-6-8 23:55:31 | 显示全部楼层
不这样处理一下,zmud的语法在mush里没法用。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|书剑永恒MUD ( 闽ICP备14012032号|闽公网安备 35050202000162号 )

GMT+8, 2025-6-4 04:20 , Processed in 0.030014 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表