mirror of
https://github.com/minetest-mods/areas.git
synced 2024-08-20 18:24:05 +02:00
Add and parse from settingtypes.txt. Update readme
This commit is contained in:
parent
5527dc8945
commit
95c1165e28
48
README.md
48
README.md
@ -1,21 +1,29 @@
|
|||||||
Areas mod for Minetest 0.4.8+
|
Areas mod for Minetest
|
||||||
=============================
|
======================
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
Minetest 5.0.0+ is recommended, but 0.4.16+ should work as well.
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
If you wish to specify configuration options, such as whether players are
|
Open the tab `Settings -> All Settings -> Mods -> areas` to get a list of all
|
||||||
allowed to protect their own areas with the `protect` command (disabled by
|
possible settings.
|
||||||
default), you should check settings.lua and set the appropriate settings in your
|
|
||||||
server's configuration file (probably `minetest.conf`).
|
For server owners: Check `settingtypes.txt` and modify your `minetest.conf`
|
||||||
|
according to the wanted setting changes.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Tutorial
|
Tutorial
|
||||||
--------
|
--------
|
||||||
|
|
||||||
To protect an area you must first set the corner positions of the area.
|
1) Specify the corner positions of the area you would like to protect.
|
||||||
In order to set the corner positions you can run:
|
Use one of the following commands:
|
||||||
|
|
||||||
* `/area_pos set` and punch the two corner nodes to set them.
|
* `/area_pos set` and punch the two corner nodes to set them.
|
||||||
* `/area_pos set1/set2` and punch only the first or second corner node to
|
* `/area_pos set1/set2` and punch only the first or second corner node to
|
||||||
set them one at a time.
|
set them one at a time.
|
||||||
@ -23,25 +31,25 @@ In order to set the corner positions you can run:
|
|||||||
* `/area_pos1/2 X Y Z` to set one of the positions to the specified
|
* `/area_pos1/2 X Y Z` to set one of the positions to the specified
|
||||||
coordinates.
|
coordinates.
|
||||||
|
|
||||||
Once you have set the border positions you can protect the area by running one
|
2) Protect the selected area by running one of the following commands:
|
||||||
of the following commands:
|
|
||||||
* `/set_owner <OwnerName> <AreaName>` -- If you have the `areas` privilege.
|
* `/set_owner <OwnerName> <AreaName>` -- If you have the `areas` privilege.
|
||||||
* `/protect <AreaName>` -- If you have the `areas` privilege or the server
|
* `/protect <AreaName>` -- If you have the `areas` privilege or the server
|
||||||
administrator has enabled area self-protection.
|
administrator has enabled area self-protection.
|
||||||
|
|
||||||
The area name is used only for informational purposes (so that you know what
|
The area name is used only for informational purposes and has no functional
|
||||||
an area is for). It is not used for any other purpose.
|
importance.
|
||||||
|
|
||||||
For example: `/set_owner SomePlayer Mese city`
|
For example: `/set_owner SomePlayer Mese city`
|
||||||
|
|
||||||
Now that you own an area you may want to add sub-owners to it. You can do this
|
3) You now own an area. You may now add sub-owners to it if you want to (see command `/add_owner`). Before using the `/add_owner` command you have to
|
||||||
with the `add_owner` command. Anyone with an area can use the `add_owner`
|
select the corners of the sub-area as you did in step 1.
|
||||||
command on their areas. Before using the `add_owner` command you have to
|
|
||||||
select the corners of the sub-area as you did for `set_owner`. If your markers
|
If your markers are still around your original area and you want to grant
|
||||||
are still around your original area and you want to grant access to your
|
access to your entire area you will not have to re-set them. Use `/select_area` to place the markers at the corners of an existing area if you've reset your
|
||||||
entire area you will not have to re-set them. You can also use `select_area` to
|
|
||||||
place the markers at the corners of an existing area if you've reset your
|
|
||||||
markers and want to grant access to a full area.
|
markers and want to grant access to a full area.
|
||||||
The `add_owner` command expects three arguments:
|
|
||||||
|
The `/add_owner` command expects three arguments:
|
||||||
1. The ID number of the parent area (the area that you want to add a
|
1. The ID number of the parent area (the area that you want to add a
|
||||||
sub-area to).
|
sub-area to).
|
||||||
2. The name of the player that will own the sub-area.
|
2. The name of the player that will own the sub-area.
|
||||||
|
45
settings.lua
45
settings.lua
@ -2,44 +2,45 @@ local world_path = minetest.get_worldpath()
|
|||||||
|
|
||||||
areas.config = {}
|
areas.config = {}
|
||||||
|
|
||||||
local function setting(tp, name, default)
|
local function setting(name, tp, default)
|
||||||
local full_name = "areas."..name
|
local full_name = "areas." .. name
|
||||||
local value
|
local value
|
||||||
if tp == "boolean" then
|
if tp == "bool" then
|
||||||
value = minetest.settings:get_bool(full_name)
|
value = minetest.settings:get_bool(full_name)
|
||||||
|
default = value == nil and minetest.is_yes(default)
|
||||||
elseif tp == "string" then
|
elseif tp == "string" then
|
||||||
value = minetest.settings:get(full_name)
|
value = minetest.settings:get(full_name)
|
||||||
elseif tp == "position" then
|
elseif tp == "v3f" then
|
||||||
value = minetest.setting_get_pos(full_name)
|
value = minetest.setting_get_pos(full_name)
|
||||||
elseif tp == "number" then
|
default = value == nil and minetest.string_to_pos(default)
|
||||||
|
elseif tp == "float" or tp == "int" then
|
||||||
value = tonumber(minetest.settings:get(full_name))
|
value = tonumber(minetest.settings:get(full_name))
|
||||||
|
local v, other = default:match("^(%S+) (.+)")
|
||||||
|
default = value == nil and tonumber(other and v or default)
|
||||||
else
|
else
|
||||||
error("Invalid setting type!")
|
error("Cannot parse setting type " .. tp)
|
||||||
end
|
end
|
||||||
|
|
||||||
if value == nil then
|
if value == nil then
|
||||||
value = default
|
value = default
|
||||||
|
assert(default ~= nil, "Cannot parse default for " .. full_name)
|
||||||
end
|
end
|
||||||
|
--print("add", name, default, value)
|
||||||
areas.config[name] = value
|
areas.config[name] = value
|
||||||
end
|
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 --
|
-- Settings --
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
setting("string", "filename", world_path.."/areas.dat")
|
setting("filename", "string", world_path.."/areas.dat")
|
||||||
|
|
||||||
-- 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)
|
|
||||||
|
|
||||||
-- legacy_table (owner_defs) compatibility. Untested and has known issues.
|
|
||||||
setting("boolean", "legacy_table", false)
|
|
||||||
|
|
||||||
-- configure the refresh delay for the name displays in the HUD
|
|
||||||
setting("number", "tick", 0.5)
|
|
||||||
|
38
settingtypes.txt
Normal file
38
settingtypes.txt
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# This file is parsed in "settings.lua". Check regex first.
|
||||||
|
|
||||||
|
# Static paths do not work well with settings
|
||||||
|
#areas.filename (Configuration file path) string (world_path)/areas.dat
|
||||||
|
|
||||||
|
# Allow players with a privilege create their own areas using /protect
|
||||||
|
# within the specified size and amount limits.
|
||||||
|
areas.self_protection (Self protection) bool false
|
||||||
|
|
||||||
|
# Self protection: Privilege required to protect an area
|
||||||
|
areas.self_protection_privilege (Self protection: Required privs) string interact
|
||||||
|
|
||||||
|
# Refresh delay for the name displays in the HUD in seconds
|
||||||
|
areas.tick (HUD update delay) float 0.5 0 100
|
||||||
|
|
||||||
|
# Enable the legacy owner_defs metatable mode. Untested and possibly unstable
|
||||||
|
areas.legacy_table (Legacy owner_defs metatable) bool false
|
||||||
|
|
||||||
|
[Self protection (normal)]
|
||||||
|
|
||||||
|
# Self protection (normal): Maximal size of the protectable area
|
||||||
|
# Only enter positive whole numbers for the coordinate values or you'll mess up stuff.
|
||||||
|
areas.self_protection_max_size (Maximal area size) v3f (64, 128, 64)
|
||||||
|
|
||||||
|
# Self protection (normal): Maximal amount of protected areas per player
|
||||||
|
areas.self_protection_max_areas (Maximal area count) int 4
|
||||||
|
|
||||||
|
[Self protection (high)]
|
||||||
|
|
||||||
|
# Self protection (normal): Maximal size of the protectable area
|
||||||
|
# This setting applies for plyaers with the privilege 'areas_high_limit'
|
||||||
|
areas.self_protection_max_size_high (Maximal area size) v3f (512, 512, 512)
|
||||||
|
|
||||||
|
# Self protection (normal): Maximal amount of protected areas per player
|
||||||
|
# Only enter positive whole numbers for the coordinate values or you'll mess up stuff.
|
||||||
|
# This setting applies for plyaers with the privilege 'areas_high_limit'
|
||||||
|
areas.self_protection_max_areas_high (Maximal area count) float 32
|
||||||
|
|
Loading…
Reference in New Issue
Block a user