forked from minetest-mods/mesecons
Add math library to luacontroller, and make sure to copy stuff so code can't get out of the sandbox.
This commit is contained in:
parent
1ff437b7b0
commit
6983db6d82
@ -195,7 +195,8 @@ local create_environment = function(pos, mem, event)
|
|||||||
mem = mem,
|
mem = mem,
|
||||||
tostring = tostring,
|
tostring = tostring,
|
||||||
tonumber = tonumber,
|
tonumber = tonumber,
|
||||||
string = string,
|
string = tablecopy(string),
|
||||||
|
math = tablecopy(math),
|
||||||
event = event}
|
event = event}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -222,6 +223,14 @@ local do_overheat = function (pos, meta)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local tablecopy = function(t)
|
||||||
|
local tnew = {}
|
||||||
|
for key, value in pairs(t) do
|
||||||
|
tnew[key] = value
|
||||||
|
end
|
||||||
|
return tnew
|
||||||
|
end
|
||||||
|
|
||||||
local load_memory = function(meta)
|
local load_memory = function(meta)
|
||||||
return minetest.deserialize(meta:get_string("lc_memory")) or {}
|
return minetest.deserialize(meta:get_string("lc_memory")) or {}
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user