forked from minetest-mods/mesecons
Explicit tables of luacontroller environment.
This commit is contained in:
parent
6983db6d82
commit
21550b3727
@ -187,7 +187,8 @@ local create_environment = function(pos, mem, event)
|
|||||||
vports = {a = vports.a, b = vports.b, c = vports.c, d = vports.d}
|
vports = {a = vports.a, b = vports.b, c = vports.c, d = vports.d}
|
||||||
local rports = get_real_portstates(pos)
|
local rports = get_real_portstates(pos)
|
||||||
|
|
||||||
return { print = safeprint,
|
return {
|
||||||
|
print = safeprint,
|
||||||
pin = merge_portstates(vports, rports),
|
pin = merge_portstates(vports, rports),
|
||||||
port = vports,
|
port = vports,
|
||||||
interrupt = getinterrupt(pos),
|
interrupt = getinterrupt(pos),
|
||||||
@ -195,9 +196,53 @@ local create_environment = function(pos, mem, event)
|
|||||||
mem = mem,
|
mem = mem,
|
||||||
tostring = tostring,
|
tostring = tostring,
|
||||||
tonumber = tonumber,
|
tonumber = tonumber,
|
||||||
string = tablecopy(string),
|
string = {
|
||||||
math = tablecopy(math),
|
byte = string.byte,
|
||||||
event = event}
|
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
|
end
|
||||||
|
|
||||||
local create_sandbox = function (code, env)
|
local create_sandbox = function (code, env)
|
||||||
@ -223,14 +268,6 @@ 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