-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.lua
42 lines (37 loc) · 1.51 KB
/
settings.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
better_commands.settings = {}
---Gets a setting and stores it in better_commands.settings
---@param setting string
---@param default any
---@param type string?
local function get_setting(setting, default, type)
local long_setting = "better_commands_"..setting
if not type or type == "string" then
better_commands.settings[setting] = minetest.settings:get(long_setting) or default
elseif type == "bool" then
better_commands.settings[setting] = minetest.settings:get_bool(long_setting, default)
elseif type == "number" then
better_commands.settings[setting] = tonumber(minetest.settings:get(long_setting)) or default
elseif type == "comma_separated" then
local value = minetest.settings:get(long_setting)
better_commands.settings[setting] = value and value:split(",") or default
end
end
local settings = {
{"override", false, "bool"},
{"acovg_time", false, "bool"},
{"save_interval", 3, "number"},
{"kill_creative_players", false, "bool"},
{"clear_lists", {"main", "craft", "offhand"}, "comma_separated"},
{"scoreboard_picked_up", true, "bool"},
{"scoreboard_mined", true, "bool"},
{"scoreboard_placed", true, "bool"},
{"scoreboard_crafted", true, "bool"},
{"scoreboard_health", true, "bool"},
{"scoreboard_death", true, "bool"},
}
function better_commands.reload_settings()
for _, setting in ipairs(settings) do
get_setting(unpack(setting))
end
end
better_commands.reload_settings()