home_workshop_modpack/computers/commands.lua

26 lines
836 B
Lua
Raw Normal View History

2022-02-13 03:56:17 +01:00
computers.registered_commands = {}
2022-02-13 06:31:20 +01:00
computers.registered_confs = {}
2022-02-13 03:56:17 +01:00
2022-02-13 16:43:41 +01:00
minetest.register_privilege("computers_filesystem", {
description = "advanced use of computers filesystem",
give_to_singleplayer = false,
give_to_admin = false,
})
2022-02-13 03:56:17 +01:00
function computers.register_command(modpath)
local func = dofile(modpath .. "/init.lua")
local f = io.open(modpath .. "/conf.json")
local conf = minetest.parse_json(f:read("*all"))
f:close()
2022-02-13 06:31:20 +01:00
if func and computers.os.version >= conf.engine then
computers.registered_commands[conf.name] = func
computers.registered_confs[conf.name] = conf
end
2022-02-13 03:56:17 +01:00
end
--load default commands
local dirs = minetest.get_dir_list(computers.modpath .. "/commands", true)
for _, dir in pairs(dirs) do
computers.register_command(computers.modpath .. "/commands/" .. dir)
end