mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-01-11 17:40:20 +01: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(...)
|
||||
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 tp = type(x)
|
||||
if tp == "function" then
|
||||
@ -463,6 +473,7 @@ local function create_environment(pos, mem, event, itbl, send_warning)
|
||||
reverse = string.reverse,
|
||||
sub = string.sub,
|
||||
find = safe_string_find,
|
||||
split = safe_string_split,
|
||||
},
|
||||
math = {
|
||||
abs = math.abs,
|
||||
@ -475,10 +486,12 @@ local function create_environment(pos, mem, event, itbl, send_warning)
|
||||
cosh = math.cosh,
|
||||
deg = math.deg,
|
||||
exp = math.exp,
|
||||
factorial = math.factorial,
|
||||
floor = math.floor,
|
||||
fmod = math.fmod,
|
||||
frexp = math.frexp,
|
||||
huge = math.huge,
|
||||
hypot = math.hypot,
|
||||
ldexp = math.ldexp,
|
||||
log = math.log,
|
||||
log10 = math.log10,
|
||||
@ -490,6 +503,7 @@ local function create_environment(pos, mem, event, itbl, send_warning)
|
||||
rad = math.rad,
|
||||
random = math.random,
|
||||
sin = math.sin,
|
||||
sing = math.sign,
|
||||
sinh = math.sinh,
|
||||
sqrt = math.sqrt,
|
||||
tan = math.tan,
|
||||
@ -497,9 +511,14 @@ local function create_environment(pos, mem, event, itbl, send_warning)
|
||||
},
|
||||
table = {
|
||||
concat = table.concat,
|
||||
copy = table.copy,
|
||||
indexof = table.indexof,
|
||||
insert = table.insert,
|
||||
insert_all = table.insert_all,
|
||||
key_value_swap = table.key_value_swap,
|
||||
maxn = table.maxn,
|
||||
remove = table.remove,
|
||||
shuffle = table.shuffle,
|
||||
sort = table.sort,
|
||||
},
|
||||
os = {
|
||||
@ -508,6 +527,24 @@ local function create_environment(pos, mem, event, itbl, send_warning)
|
||||
time = os.time,
|
||||
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
|
||||
|
||||
@ -901,4 +938,3 @@ minetest.register_craft({
|
||||
{'group:mesecon_conductor_craftable', 'group:mesecon_conductor_craftable', ''},
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user