aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-12-18 11:56:48 +0100
committerorwell96 <orwell@bleipb.de>2018-12-18 11:56:48 +0100
commitb332a31d4886d5699575c933627c91f659ab45b8 (patch)
tree29ac0ddc19c224635c0c8f1cbce0fd226b3bc428 /advtrains
parent36357bd444106282890278092c474eaf397bd8a9 (diff)
downloadadvtrains-b332a31d4886d5699575c933627c91f659ab45b8.tar.gz
advtrains-b332a31d4886d5699575c933627c91f659ab45b8.tar.bz2
advtrains-b332a31d4886d5699575c933627c91f659ab45b8.zip
Make track protection radius configurable
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/protection.lua15
-rw-r--r--advtrains/settingtypes.txt19
2 files changed, 29 insertions, 5 deletions
diff --git a/advtrains/protection.lua b/advtrains/protection.lua
index 1ea4957..7474977 100644
--- a/advtrains/protection.lua
+++ b/advtrains/protection.lua
@@ -28,6 +28,14 @@ minetest.register_privilege("railway_operator", {
-- there is a configuration option "allow_build_only_owner". If this is active, a player having track_builder can only build rails and operate signals/turnouts in an area explicitly belonging to him
-- (checked using a dummy player called "*dummy*" (which is not an allowed player name))
+
+-- Protection ranges
+local npr_r = tonumber(minetest.settings:get("advtrains_prot_range_side")) or 1
+local npr_vr = tonumber(minetest.settings:get("advtrains_prot_range_up")) or 3
+local npr_vrd = tonumber(minetest.settings:get("advtrains_prot_range_down")) or 1
+
+local boo = minetest.settings:get_bool("advtrains_allow_build_to_owner")
+
--[[
Protection/privilege concept:
Tracks:
@@ -59,8 +67,6 @@ Wagon coupling:
]]--
-local boo = minetest.settings:get_bool("advtrains_allow_build_to_owner")
-
-- temporarily prevent scanning for neighboring rail nodes recursively
local nocheck
@@ -92,10 +98,9 @@ minetest.is_protected = function(pos, pname)
return not advtrains.check_track_protection(pos, pname, nil, false)
end
- local r, vr = 1, 3
local nodes = minetest.find_nodes_in_area(
- {x = pos.x - r, y = pos.y - vr, z = pos.z - r},
- {x = pos.x + r, y = pos.y + 1, z = pos.z + r},
+ {x = pos.x - npr_r, y = pos.y - npr_vr, z = pos.z - npr_r},
+ {x = pos.x + npr_r, y = pos.y + npr_vrd, z = pos.z + npr_r},
{"group:advtrains_track"})
for _,npos in ipairs(nodes) do
if not advtrains.check_track_protection(npos, pname, pos) then
diff --git a/advtrains/settingtypes.txt b/advtrains/settingtypes.txt
index 1c4974f..49df423 100644
--- a/advtrains/settingtypes.txt
+++ b/advtrains/settingtypes.txt
@@ -1,16 +1,35 @@
# Display train and wagon ID in the infotext of trains.
# Useful when working with LuaATC or while debugging.
advtrains_show_ids (Show ID's in infotext) bool false
+
# Enable the debug ring buffer
# This has no effect on the user experience, except decreased performance. Debug outputs are saved in a ring buffer to be printed when an error occurs.
# You probably want to leave this setting set to false.
advtrains_enable_debugging (Enable debugging) bool false
+
# Enable the logging of certain events related to advtrains
# Logs are saved in the world directory as advtrains.log
# This setting is useful for multiplayer servers
advtrains_enable_logging (Enable logging) bool false
+
# If this is active, any player can do the following things inside (and only inside) an area that is explicitly protected by him
# (checked using a dummy player called "*dummy*" (which is not an allowed player name)):
# - build tracks and near tracks without the track_builder privilege
# - operate turnouts and signals without the railway_operator privilege
advtrains_allow_build_to_owner (Allow building/operating to privilegeless area owner) bool false
+
+# Track protection range (horizontal)
+# Players without the 'track_builder' privilege can not build within a box around any tracks determined by these range settings
+# This setting is to be read as "r-0.5", so a value of 1 means a diameter of 3, a value of 2 a diameter of 5 a.s.o.
+# The spanned area is a square. Fractional values are not supported.
+advtrains_prot_range_side (Track protection range [horizontal]) int 1 0 10
+
+# Track protection range (up)
+# Players without the 'track_builder' privilege can not build within a box around any tracks determined by these range settings
+# This setting determines the upper y bound of the box, a value of 3 means that the rail and 3 nodes above it are protected
+advtrains_prot_range_up (Track protection range [up]) int 3 0 10
+
+# Track protection range (down)
+# Players without the 'track_builder' privilege can not build within a box around any tracks determined by these range settings
+# This setting determines the lower y bound of the box, a value of 1 means that the rail and 1 node below it are protected
+advtrains_prot_range_down (Track protection range [down]) int 1 0 10 \ No newline at end of file