Make track protection radius configurable

master
orwell96 2018-12-18 11:56:48 +01:00
parent 36357bd444
commit b332a31d48
2 changed files with 29 additions and 5 deletions

View File

@ -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

View File

@ -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