mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2024-11-14 14:40:19 +01:00
code review fix
This commit is contained in:
parent
38a370c123
commit
73b9cd1776
|
@ -13,22 +13,22 @@ function worldedit.lua(code, name)
|
|||
end
|
||||
local factory, err = loadstring("return function(name, player, pos) " .. code .. " end")
|
||||
if not factory then -- Syntax error
|
||||
return false, err
|
||||
return err
|
||||
end
|
||||
local func=factory()
|
||||
local player
|
||||
if name then
|
||||
player=minetest.get_player_by_name(name)
|
||||
player = minetest.get_player_by_name(name)
|
||||
end
|
||||
local pos
|
||||
if player then
|
||||
pos=vector.round(player:get_pos())
|
||||
pos = vector.round(player:get_pos())
|
||||
end
|
||||
local good, err = pcall(func, name, player, pos)
|
||||
if good then
|
||||
err=dump(err)
|
||||
return nil, dump(err)
|
||||
end
|
||||
return good, err
|
||||
return err
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1528,16 +1528,16 @@ worldedit.register_command("lua", {
|
|||
return true, param
|
||||
end,
|
||||
func = function(name, param)
|
||||
local good, ret = worldedit.lua(param, name)
|
||||
if good then
|
||||
if ret ~= "nil" then
|
||||
worldedit.player_notify(name, "code successfully executed, returns with " .. ret, false)
|
||||
local ret = {worldedit.lua(param, name)}
|
||||
if type(ret[1]) == "nil" then
|
||||
if ret[2] ~= "nil" then
|
||||
worldedit.player_notify(name, "code successfully executed, returns with " .. ret[2], false)
|
||||
else
|
||||
worldedit.player_notify(name, "code successfully executed", false)
|
||||
end
|
||||
minetest.log("action", name .. " executed " .. param)
|
||||
else
|
||||
worldedit.player_notify(name, "code error: " .. dump(ret))
|
||||
worldedit.player_notify(name, "code error: " .. dump(ret[1]))
|
||||
minetest.log("action", name .. " tried to execute " .. param)
|
||||
end
|
||||
end,
|
||||
|
|
Loading…
Reference in New Issue
Block a user