Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create debugLua.lua #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions data/scripts/talkactions/debugLua.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function sendToPlayerLuaCallResult(player, ...)
local n = select('#', ...)
local result = setmetatable({ ... }, {
__len = function()
return n
end,
})

local t = {}
for i = 2, #result do
local v = tostring(result[i])
if v:len() > 0 then
table.insert(t, v)
end
end

if #t > 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, table.concat(t, ', '))
end
end


local talk = TalkAction("/lua")
function talk.onSay(player, words, param)
if player:getGroup():getId() < 6 then
return false
end

if player:getAccountType() < ACCOUNT_TYPE_GOD then
return false
end

sendToPlayerLuaCallResult(player, pcall(loadstring(
'local cid = ' .. player:getId() .. ' ' ..
'local player = Player(cid) ' ..
'local pos = player:getPosition() ' ..
'local position = pos ' ..
param
)))

return false
end

talk:separator(" ")
talk:register()
Loading