forked from minetest-mods/areas
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsettings.lua
More file actions
50 lines (44 loc) · 1.54 KB
/
settings.lua
File metadata and controls
50 lines (44 loc) · 1.54 KB
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
43
44
45
46
47
48
49
50
local world_path = minetest.get_worldpath()
areas.config = {}
local function setting(tp, name, default)
local full_name = "areas." .. name
local value
if tp == "boolean" then
value = minetest.settings:get_bool(full_name)
elseif tp == "string" then
value = minetest.settings:get(full_name)
elseif tp == "position" then
value = minetest.setting_get_pos(full_name)
elseif tp == "number" then
value = tonumber(minetest.settings:get(full_name))
else
error("Cannot parse setting type " .. tp)
end
if value == nil then
value = default
end
areas.config[name] = value
end
--------------
-- Settings --
--------------
setting("string", "filename", world_path.."/areas.dat")
setting("boolean", "pvp_by_default", false)
setting("number", "max_area_name_length", 40)
setting("number", "pvp_cooldown", 0.2)
-- Allow players with a privilege create their own areas
-- within the maximum size and number.
setting("boolean", "self_protection", true)
setting("string", "self_protection_privilege", "interact")
setting("position", "self_protection_max_size", {x = 128, y = 128, z = 128})
setting("number", "self_protection_max_areas", 16)
-- For players with the areas_high_limit privilege.
local base_size = areas.config["self_protection_max_size"]
local base_areas = areas.config["self_protection_max_areas"]
setting("position", "self_protection_max_size_high", {
x = base_size.x * 4,
y = base_size.y * 4,
z = base_size.z * 4
})
setting("number", "self_protection_max_areas_high", base_areas * 4)
setting("number", "self_max_areas_per_player", 1024)