-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify settings definitions and namespace settings
- Loading branch information
1 parent
e4aef02
commit 3f77790
Showing
5 changed files
with
45 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,43 @@ | ||
local worldpath = minetest.get_worldpath() | ||
local world_path = minetest.get_worldpath() | ||
|
||
local function setting_getbool_default(setting, default) | ||
local value = minetest.setting_getbool(setting) | ||
areas.config = {} | ||
|
||
local function setting(tp, name, default) | ||
local full_name = "areas."..name | ||
local value | ||
if tp == "boolean" then | ||
value = minetest.setting_getbool(full_name) | ||
elseif tp == "string" then | ||
value = minetest.setting_get(full_name) | ||
elseif tp == "position" then | ||
value = minetest.setting_get_pos(full_name) | ||
elseif tp == "number" then | ||
value = tonumber(minetest.setting_get(full_name)) | ||
else | ||
error("Invalid setting type!") | ||
end | ||
if value == nil then | ||
value = default | ||
end | ||
return value | ||
areas.config[name] = value | ||
end | ||
|
||
areas.filename = | ||
minetest.setting_get("areas.filename") or worldpath.."/areas.dat" | ||
-------------- | ||
-- Settings -- | ||
-------------- | ||
|
||
-- Allow players with a privilege create their own areas | ||
-- within the maximum size and number | ||
areas.self_protection = | ||
setting_getbool_default("areas.self_protection", false) | ||
areas.self_protection_privilege = | ||
minetest.setting_get("areas.self_protection_privilege") or "interact" | ||
areas.self_protection_max_size = | ||
minetest.setting_get_pos("areas.self_protection_max_size") or | ||
{x=64, y=128, z=64} | ||
areas.self_protection_max_size_high = | ||
minetest.setting_get_pos("areas.self_protection_max_size_high") or | ||
{x=512, y=512, z=512} | ||
areas.self_protection_max_areas = | ||
tonumber(minetest.setting_get("areas.self_protection_max_areas")) or 4 | ||
areas.self_protection_max_areas_high = | ||
tonumber(minetest.setting_get("areas.self_protection_max_areas_high")) or 32 | ||
setting("string", "filename", world_path.."/areas.dat") | ||
|
||
-- Register compatability functions for node_ownership. | ||
-- legacy_table (owner_defs) compatibility is untested | ||
-- and can not be used if security_safe_mod_api is on. | ||
areas.legacy_table = | ||
setting_getbool_default("areas.legacy_table", false) | ||
-- Allow players with a privilege create their own areas | ||
-- within the maximum size and number. | ||
setting("boolean", "self_protection", false) | ||
setting("string", "self_protection_privilege", "interact") | ||
setting("position", "self_protection_max_size", {x=64, y=128, z=64}) | ||
setting("number", "self_protection_max_areas", 4) | ||
-- For players with the areas_high_limit privilege. | ||
setting("position", "self_protection_max_size_high", {x=512, y=512, z=512}) | ||
setting("number", "self_protection_max_areas_high", 32) | ||
|
||
-- Prevent players from punching nodes in a protected area. | ||
-- Usefull for things like delayers, usualy annoying and | ||
-- prevents usage of things like buttons. | ||
areas.protect_punches = | ||
setting_getbool_default("areas.protect_punches", false) | ||
-- legacy_table (owner_defs) compatibility. Untested and has known issues. | ||
setting("boolean", "legacy_table", false) | ||
|
3f77790
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might have broken something. Command /list_areas returns