1.0 - Funcionamento:
Explicação:Este talkaction, apenas faz a execução de um comando em lua, direto do game.
Exemplos:
2.0 - Como Utilizar:
Executando apenas uma função: /lua Função('variavél', 'variável', 'variável')
Executando várias funções simultâneas: /lua Função('variável', variável'), Função('variável', variável', variável'), ...
3.0 - Instalação:
-
Talkactions.xml
Spoiler
<talkaction words="/lua" access="5" event="script" value="lua.lua"
-
Data/Talkactions/scripts/lua.lua
Spoiler
function resolveFunction (cid, func) temp_var = {} fn = string.gsub(func, "%b()", "") _, count = string.gsub(func, "'([(%w%s_]+)'", function (var) if (tonumber(var) ~= nil) then table.insert(temp_var, tonumber(var)) else table.insert(temp_var, var) end end) if (count == 2) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, fn .. "("..temp_var[1]..", ".. temp_var[2]..")") if (temp_var[1] == "cid") then temp_var[1] = cid else temp_var[1] = getPlayerByNameWildcard(temp_var[1]) end _G[fn](temp_var[1], temp_var[2]) elseif (count == 3) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, fn .. "("..temp_var[1]..", ".. temp_var[2]..", ".. temp_var[3] ..")") if (temp_var[1] == "cid") then temp_var[1] = cid else temp_var[1] = getPlayerByNameWildcard(temp_var[1]) end _G[fn](temp_var[1], temp_var[2], temp_var[3]) elseif (count >= 4 or count < 2) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Not implemented") end end function onSay(cid, words, param, channel) funktions = {} _, count = string.gsub(param, "((%w+)%b())", function (func) table.insert(funktions, func) end) for _, i in pairs (funktions) do resolveFunction(cid, i) end return true end
OBS.: Na versão atual, ainda não se é possível utilizar uma função dentro de outra, e nem funções de retorno (getters)
Créditos: Desenvolvido inteiramente por mim (Vítor Subhi).