fix crash on dump because of assumtion that every ref as is_valid
This commit is contained in:
parent
44d24e549d
commit
86b59e4d08
10
dump.lua
10
dump.lua
@ -55,7 +55,9 @@ local function basic_dump(o)
|
|||||||
--elseif tp == "function" then
|
--elseif tp == "function" then
|
||||||
-- return string.format("loadstring(%q)", string.dump(o))
|
-- return string.format("loadstring(%q)", string.dump(o))
|
||||||
elseif tp == "userdata" then
|
elseif tp == "userdata" then
|
||||||
if o:is_valid() then
|
if o.is_valid and not o:is_valid() then
|
||||||
|
return string.format('#<invalid_ref: %s>', o)
|
||||||
|
end
|
||||||
if o.is_player then
|
if o.is_player then
|
||||||
if o:is_player() then
|
if o:is_player() then
|
||||||
return string.format('#<player: "%s">', o:get_player_name())
|
return string.format('#<player: "%s">', o:get_player_name())
|
||||||
@ -67,12 +69,8 @@ local function basic_dump(o)
|
|||||||
return string.format('#<ObjectRef: %s>', o)
|
return string.format('#<ObjectRef: %s>', o)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
return tostring(o)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return string.format('#<invalid_ref: %s>', o)
|
|
||||||
end
|
end
|
||||||
|
return string.format("#<%s>", o)
|
||||||
else
|
else
|
||||||
return string.format("#<%s>", tp)
|
return string.format("#<%s>", tp)
|
||||||
end
|
end
|
||||||
|
2
init.lua
2
init.lua
@ -75,7 +75,7 @@ local function create_shared_environment(player_name)
|
|||||||
return magic()
|
return magic()
|
||||||
elseif not g[key] then
|
elseif not g[key] then
|
||||||
core.chat_send_player(player_name, string.format("* Accessing undeclared variable: '%s'", key))
|
core.chat_send_player(player_name, string.format("* Accessing undeclared variable: '%s'", key))
|
||||||
g[key] = true
|
g[key] = true -- warn only once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return res
|
return res
|
||||||
|
Loading…
Reference in New Issue
Block a user