lua 根据字符串调用函数
local GMDirective =
{
}
function SetRoleLV(nRoleID)
print("test",nRoleID)
end
table.insert(GMDirective,SetRoleLV)
for k,v in pairs(GMDirective) do
v(100)
end
function SetRoleLV(nRoleID)
print("test",nRoleID)
end
function GetItem(nRoleID,nItemID)
print(nRoleID,nItemID)
end
local GMDirective =
{
["SetRoleLV"]={SetRoleLV,1},
["GetItem"]={GetItem,2}
}
local MsgTable = {1,2,3,4,5}
for k,v in pairs(GMDirective) do
GMDirective[k][1](MsgTable[1],MsgTable[2])
end
local fun = loadstring(GMDirective[FucName]) if type(fun) == "function" then fun(pPlayer,MSGTable) end

浙公网安备 33010602011771号