summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Zhang <azhang9@gmail.com>2013-03-23 17:49:25 -0400
committerAnthony Zhang <azhang9@gmail.com>2013-03-23 17:49:25 -0400
commit6983db6d82b5b415c5e141aa360b46efa3e3a209 (patch)
tree7e51a27c5787d392e4029d13722eaef3aa5169a5
parent1ff437b7b0b7ebd5f2faf1e2f1e7dcba027beb6b (diff)
downloadmesecons-6983db6d82b5b415c5e141aa360b46efa3e3a209.tar
mesecons-6983db6d82b5b415c5e141aa360b46efa3e3a209.tar.gz
mesecons-6983db6d82b5b415c5e141aa360b46efa3e3a209.tar.bz2
mesecons-6983db6d82b5b415c5e141aa360b46efa3e3a209.tar.xz
mesecons-6983db6d82b5b415c5e141aa360b46efa3e3a209.zip
Add math library to luacontroller, and make sure to copy stuff so code can't get out of the sandbox.
-rw-r--r--mesecons_luacontroller/init.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua
index 9a835ac..ff429b8 100644
--- a/mesecons_luacontroller/init.lua
+++ b/mesecons_luacontroller/init.lua
@@ -195,7 +195,8 @@ local create_environment = function(pos, mem, event)
mem = mem,
tostring = tostring,
tonumber = tonumber,
- string = string,
+ string = tablecopy(string),
+ math = tablecopy(math),
event = event}
end
@@ -222,6 +223,14 @@ local do_overheat = function (pos, meta)
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)
return minetest.deserialize(meta:get_string("lc_memory")) or {}
end