-3

编译此 lua 脚本时出现错误。LUA 编辑器和 ptokaX Server 似乎是这么认为的。我无法弄清楚错误。LUA 编辑器说错误在 dofile(path.."files/mcunsubs.txt") 中。PtokaX 编辑器说错误出现在这部分代码中:

data = data:gsub( "[\|]", "" )          
data = data:gsub( "\&\#124\;", "\|" )
data = data:gsub( "\&\#036\;", "\$" )

这是代码。

--[[
This file is part of HiT Hi FiT Hai's PtokaX scripts
Copyright: © 2014 HiT Hi FiT Hai group
Licence: GNU General Public Licence v3 https://www.gnu.org/licenses/gpl-3.0.html
--]]

unsubbed={}
subbed={}
dofile( path.."files/mcunsubs.txt" )
tabUsers = Core.GetOnlineUsers()

for k,v in ipairs(tabUsers) do
    if not isthere_key(v.sNick,unsubbed) then
        table.insert(subbed,v.sNick)
    end
end

ircout = function(data)
    data = data:gsub( "[\|]", "" )  --  Removing the terminating '|'     character only.
    data = data:gsub( "\&\#124\;", "\|" )
    data = data:gsub( "\&\#036\;", "\$" )
    local file= io.open("/root/DCout.txt","a+")
    file:write(data.."\n")
    file:flush()
    file:close()
   end

dcmcout = function(data)
    for k,v in ipairs(subbed) do
        Core.SendToNick(v,data)
    end
end

UserConnected= function (tUser)
    if not isthere_key(tUser.sNick,unsubbed) then
        if not isthere_key(tUser.sNick,subbed) then
            table.insert(subbed,tUser.sNick)
        end
    end
end 
RegConnected = UserConnected
OpConnected = UserConnected
UserDisConnected= function (tUser)
    key = isthere_key(tUser.sNick,subbed)
    while key do
        table.remove( subbed, key)
        key = isthere_key(user.sNick,subbed)
    end
end
RegDisConnected = UserDisConnected
OpDisConnected = UserDisConnected

4

1 回答 1

0

Lua 编辑器(我假设它是SciTE )在第 12 行给你错误,因为 SciTE 无法识别Core下一行中的表:

tabUsers = Core.GetOnlineUsers()

当您在 PtokaX 中执行相同的脚本时,该Core表已定义并且在那里没有遇到错误。由于您使用的 Lua 版本比最初编写此文件的版本更新(为 Lua 5.1 编写,您使用的是 Lua 5.2),因此您会收到错误消息。Lua 5.1 对错误的字符串匹配模式更加宽容,而后者不是。

对于解决方案,您可以使用以下内容:

data = data:gsub( "|", "" ):gsub( "|", "|" ):gsub( "$", "$" )
于 2014-05-01T22:18:12.657 回答