forked from random-geek/meshport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.lua
36 lines (32 loc) · 1.07 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
meshport.config = {}
-- taken from https://github.com/minetest-mods/areas/
local function setting(name, tp, default, config)
local full_name = core.get_current_modname().."." .. name
local value
if tp == "bool" then
value = core.settings:get_bool(full_name)
default = value == nil and core.is_yes(default)
elseif tp == "string" then
value = core.settings:get(full_name)
elseif tp == "v3f" then
value = core.setting_get_pos(full_name)
default = value == nil and core.string_to_pos(default)
elseif tp == "float" or tp == "int" then
value = tonumber(core.settings:get(full_name))
local v, other = default:match("^(%S+) (.+)")
default = value == nil and tonumber(other and v or default)
else
error("Cannot parse setting type " .. tp)
end
if value == nil then
value = default
assert(default ~= nil, "Cannot parse default for " .. full_name)
end
--print("add", name, default, value)
config[name] = value
end
--------------
-- Settings --
--------------
setting("webhook_url", "string", "", meshport.config)
setting("embed_textures", "bool", false, meshport.config)