Revert 'Add and parse from settingtypes.txt'
parent
78cd229451
commit
e5f6097714
42
settings.lua
42
settings.lua
|
@ -2,45 +2,41 @@ local world_path = minetest.get_worldpath()
|
|||
|
||||
areas.config = {}
|
||||
|
||||
local function setting(name, tp, default)
|
||||
local full_name = "areas." .. name
|
||||
local function setting(tp, name, default)
|
||||
local full_name = "areas."..name
|
||||
local value
|
||||
if tp == "bool" then
|
||||
if tp == "boolean" then
|
||||
value = minetest.settings:get_bool(full_name)
|
||||
default = value == nil and minetest.is_yes(default)
|
||||
elseif tp == "string" then
|
||||
value = minetest.settings:get(full_name)
|
||||
elseif tp == "v3f" then
|
||||
elseif tp == "position" then
|
||||
value = minetest.setting_get_pos(full_name)
|
||||
default = value == nil and minetest.string_to_pos(default)
|
||||
elseif tp == "float" or tp == "int" then
|
||||
elseif tp == "number" then
|
||||
value = tonumber(minetest.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)
|
||||
error("Invalid setting type!")
|
||||
end
|
||||
|
||||
if value == nil then
|
||||
value = default
|
||||
assert(default ~= nil, "Cannot parse default for " .. full_name)
|
||||
end
|
||||
--print("add", name, default, value)
|
||||
areas.config[name] = value
|
||||
end
|
||||
|
||||
local file = io.open(areas.modpath .. "/settingtypes.txt", "r")
|
||||
for line in file:lines() do
|
||||
local name, tp, value = line:match("^areas%.(%S+) %(.*%) (%S+) (.*)")
|
||||
if value then
|
||||
setting(name, tp, value)
|
||||
end
|
||||
end
|
||||
file:close()
|
||||
|
||||
--------------
|
||||
-- Settings --
|
||||
--------------
|
||||
|
||||
setting("filename", "string", world_path.."/areas.dat")
|
||||
setting("string", "filename", world_path.."/areas.dat")
|
||||
|
||||
-- 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 = 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)
|
||||
|
||||
-- configure the refresh delay for the name displays in the HUD
|
||||
setting("number", "tick", 1)
|
Loading…
Reference in New Issue