modlib/minetest.lua

67 lines
1.3 KiB
Lua
Raw Permalink Normal View History

local _ENV = {}
local components = {}
for _, value in pairs{
"luon",
"raycast",
"schematic",
2021-08-29 11:41:10 +02:00
"colorspec",
"media"
} do
components[value] = value
2021-06-17 19:45:08 +02:00
end
for filename, comps in pairs{
misc = {
"max_wear",
"override",
2021-08-16 18:20:01 +02:00
"after",
"register_globalstep",
"form_listeners",
"register_form_listener",
"texture_modifier_inventorycube",
"get_node_inventory_image",
"check_player_privs",
"decode_base64",
"objects_inside_radius",
"objects_inside_area",
2021-08-16 18:21:49 +02:00
"nodename_matcher",
"playerdata",
"connected_players",
2021-09-15 18:51:10 +02:00
"set_privs",
"register_on_leaveplayer",
"get_mod_info",
"get_mod_load_order"
},
liquid = {
"liquid_level_max",
"get_liquid_corner_levels",
"flowing_downwards",
"get_liquid_flow_direction"
},
wielditem_change = {
"players",
"registered_on_wielditem_changes",
"register_on_wielditem_change"
},
colorspec = {
"named_colors",
"colorspec_to_colorstring"
},
collisionboxes = {
"get_node_collisionboxes"
}
} do
for _, component in pairs(comps) do
components[component] = filename
end
end
setmetatable(_ENV, {__index = function(_ENV, name)
local filename = components[name]
if filename then
assert(loadfile(modlib.mod.get_resource(modlib.modname, "minetest", filename .. ".lua")))(_ENV)
return rawget(_ENV, name)
end
end})
2021-06-17 19:45:08 +02:00
return _ENV