mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-03-30 17:00:26 +02:00
Add all usefull helper function from lua_api.txt
This commit is contained in:
parent
68c1729990
commit
077cdaa2a4
@ -231,6 +231,16 @@ local function safe_string_find(...)
|
|||||||
return string.find(...)
|
return string.find(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- do not allow pattern matching in string.split (see string.find for details)
|
||||||
|
local function safe_string_split(...)
|
||||||
|
if select(5, ...) then
|
||||||
|
debug.sethook() -- Clear hook
|
||||||
|
error("string.split: 'sep_is_pattern' (fifth parameter) may not be used in a Luacontroller")
|
||||||
|
end
|
||||||
|
|
||||||
|
return string.split(...)
|
||||||
|
end
|
||||||
|
|
||||||
local function remove_functions(x)
|
local function remove_functions(x)
|
||||||
local tp = type(x)
|
local tp = type(x)
|
||||||
if tp == "function" then
|
if tp == "function" then
|
||||||
@ -463,6 +473,7 @@ local function create_environment(pos, mem, event, itbl, send_warning)
|
|||||||
reverse = string.reverse,
|
reverse = string.reverse,
|
||||||
sub = string.sub,
|
sub = string.sub,
|
||||||
find = safe_string_find,
|
find = safe_string_find,
|
||||||
|
split = safe_string_split,
|
||||||
},
|
},
|
||||||
math = {
|
math = {
|
||||||
abs = math.abs,
|
abs = math.abs,
|
||||||
@ -475,10 +486,12 @@ local function create_environment(pos, mem, event, itbl, send_warning)
|
|||||||
cosh = math.cosh,
|
cosh = math.cosh,
|
||||||
deg = math.deg,
|
deg = math.deg,
|
||||||
exp = math.exp,
|
exp = math.exp,
|
||||||
|
factorial = math.factorial,
|
||||||
floor = math.floor,
|
floor = math.floor,
|
||||||
fmod = math.fmod,
|
fmod = math.fmod,
|
||||||
frexp = math.frexp,
|
frexp = math.frexp,
|
||||||
huge = math.huge,
|
huge = math.huge,
|
||||||
|
hypot = math.hypot,
|
||||||
ldexp = math.ldexp,
|
ldexp = math.ldexp,
|
||||||
log = math.log,
|
log = math.log,
|
||||||
log10 = math.log10,
|
log10 = math.log10,
|
||||||
@ -490,6 +503,7 @@ local function create_environment(pos, mem, event, itbl, send_warning)
|
|||||||
rad = math.rad,
|
rad = math.rad,
|
||||||
random = math.random,
|
random = math.random,
|
||||||
sin = math.sin,
|
sin = math.sin,
|
||||||
|
sing = math.sign,
|
||||||
sinh = math.sinh,
|
sinh = math.sinh,
|
||||||
sqrt = math.sqrt,
|
sqrt = math.sqrt,
|
||||||
tan = math.tan,
|
tan = math.tan,
|
||||||
@ -497,9 +511,14 @@ local function create_environment(pos, mem, event, itbl, send_warning)
|
|||||||
},
|
},
|
||||||
table = {
|
table = {
|
||||||
concat = table.concat,
|
concat = table.concat,
|
||||||
|
copy = table.copy,
|
||||||
|
indexof = table.indexof,
|
||||||
insert = table.insert,
|
insert = table.insert,
|
||||||
|
insert_all = table.insert_all,
|
||||||
|
key_value_swap = table.key_value_swap,
|
||||||
maxn = table.maxn,
|
maxn = table.maxn,
|
||||||
remove = table.remove,
|
remove = table.remove,
|
||||||
|
shuffle = table.shuffle,
|
||||||
sort = table.sort,
|
sort = table.sort,
|
||||||
},
|
},
|
||||||
os = {
|
os = {
|
||||||
@ -508,6 +527,24 @@ local function create_environment(pos, mem, event, itbl, send_warning)
|
|||||||
time = os.time,
|
time = os.time,
|
||||||
datetable = safe_date,
|
datetable = safe_date,
|
||||||
},
|
},
|
||||||
|
dump2 = dump2,
|
||||||
|
dump = dump,
|
||||||
|
minetest = {
|
||||||
|
wrap_text = minetest.wrap_text,
|
||||||
|
pos_to_string = minetest.pos_to_string,
|
||||||
|
string_to_pos = minetest.string_to_pos,
|
||||||
|
string_to_area = minetest.string_to_area,
|
||||||
|
formspec_escape = minetest.formspec_escape,
|
||||||
|
is_yes = minetest.is_yes,
|
||||||
|
is_nan = minetest.is_nan,
|
||||||
|
get_us_time = minetest.get_us_time,
|
||||||
|
parse_json = minetest.parse_json,
|
||||||
|
write_json = minetest.write_json,
|
||||||
|
rgba = minetest.rgba,
|
||||||
|
encode_base64 = minetest.encode_base64,
|
||||||
|
decode_base64 = minetest.decode_base64,
|
||||||
|
},
|
||||||
|
vector = vector,
|
||||||
}
|
}
|
||||||
env._G = env
|
env._G = env
|
||||||
|
|
||||||
@ -901,4 +938,3 @@ minetest.register_craft({
|
|||||||
{'group:mesecon_conductor_craftable', 'group:mesecon_conductor_craftable', ''},
|
{'group:mesecon_conductor_craftable', 'group:mesecon_conductor_craftable', ''},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user