summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Zhang <azhang9@gmail.com>2013-03-23 18:41:44 -0400
committerAnthony Zhang <azhang9@gmail.com>2013-03-23 18:41:44 -0400
commit21550b37277f3ca8c39734f52d318db885b9ff27 (patch)
tree7fc8749f7e967bf98a48c97cbc78574dff999b27
parent6983db6d82b5b415c5e141aa360b46efa3e3a209 (diff)
downloadmesecons-21550b37277f3ca8c39734f52d318db885b9ff27.tar
mesecons-21550b37277f3ca8c39734f52d318db885b9ff27.tar.gz
mesecons-21550b37277f3ca8c39734f52d318db885b9ff27.tar.bz2
mesecons-21550b37277f3ca8c39734f52d318db885b9ff27.tar.xz
mesecons-21550b37277f3ca8c39734f52d318db885b9ff27.zip
Explicit tables of luacontroller environment.
-rw-r--r--mesecons_luacontroller/init.lua61
1 files changed, 49 insertions, 12 deletions
diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua
index ff429b8..37e95c4 100644
--- a/mesecons_luacontroller/init.lua
+++ b/mesecons_luacontroller/init.lua
@@ -187,7 +187,8 @@ local create_environment = function(pos, mem, event)
vports = {a = vports.a, b = vports.b, c = vports.c, d = vports.d}
local rports = get_real_portstates(pos)
- return { print = safeprint,
+ return {
+ print = safeprint,
pin = merge_portstates(vports, rports),
port = vports,
interrupt = getinterrupt(pos),
@@ -195,9 +196,53 @@ local create_environment = function(pos, mem, event)
mem = mem,
tostring = tostring,
tonumber = tonumber,
- string = tablecopy(string),
- math = tablecopy(math),
- event = event}
+ string = {
+ byte = string.byte,
+ char = string.char,
+ find = string.find,
+ format = string.format,
+ gmatch = string.gmatch,
+ gsub = string.gsub,
+ len = string.len,
+ lower = string.lower,
+ match = string.match,
+ rep = string.rep,
+ reverse = string.reverse,
+ sub = string.sub,
+ },
+ math = {
+ abs = math.abs,
+ acos = math.acos,
+ asin = math.asin,
+ atan = math.atan,
+ atan2 = math.atan2,
+ ceil = math.ceil,
+ cos = math.cos,
+ cosh = math.cosh,
+ deg = math.deg,
+ exp = math.exp,
+ floor = math.floor,
+ fmod = math.fmod,
+ frexp = math.frexp,
+ huge = math.huge,
+ ldexp = math.ldexp,
+ log = math.log,
+ log10 = math.log10,
+ max = math.max,
+ min = math.min,
+ modf = math.modf,
+ pi = math.pi,
+ pow = math.pow,
+ rad = math.rad,
+ random = math.random,
+ sin = math.sin,
+ sinh = math.sinh,
+ sqrt = math.sqrt,
+ tan = math.tan,
+ tanh = math.tanh,
+ },
+ event = event,
+ }
end
local create_sandbox = function (code, env)
@@ -223,14 +268,6 @@ 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