diff --git a/worldedit/code.lua b/worldedit/code.lua index 87a94ec..de2df0b 100644 --- a/worldedit/code.lua +++ b/worldedit/code.lua @@ -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 diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua index 31c4498..c5a5c48 100644 --- a/worldedit_commands/init.lua +++ b/worldedit_commands/init.lua @@ -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,