diff options
-rw-r--r-- | advtrains.zip | bin | 4986437 -> 4986626 bytes | |||
-rw-r--r-- | advtrains/advtrains/signals.lua | 18 | ||||
-rw-r--r-- | advtrains/advtrains/tracks.lua | 18 | ||||
-rw-r--r-- | advtrains/advtrains/wagons.lua | 10 |
4 files changed, 31 insertions, 15 deletions
diff --git a/advtrains.zip b/advtrains.zip Binary files differindex 22c0e4d..226e34e 100644 --- a/advtrains.zip +++ b/advtrains.zip diff --git a/advtrains/advtrains/signals.lua b/advtrains/advtrains/signals.lua index ceb4166..a5a9aa3 100644 --- a/advtrains/advtrains/signals.lua +++ b/advtrains/advtrains/signals.lua @@ -41,8 +41,10 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_"..f.as..rotation, param2 = node.param2}) end }}, - on_rightclick=function(pos, node, clicker) - advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_"..f.as..rotation, param2 = node.param2}) + on_rightclick=function(pos, node, player) + if minetest.check_player_privs(player:get_player_name(), {train_operator=true}) then + advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_"..f.as..rotation, param2 = node.param2}) + end end, }) advtrains.trackplacer.add_worked("advtrains:retrosignal", r, rotation, nil) @@ -83,8 +85,10 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", end end, }, - on_rightclick=function(pos, node, clicker) - advtrains.ndb.swap_node(pos, {name = "advtrains:signal_"..f.as..rotation, param2 = node.param2}) + on_rightclick=function(pos, node, player) + if minetest.check_player_privs(player:get_player_name(), {train_operator=true}) then + advtrains.ndb.swap_node(pos, {name = "advtrains:signal_"..f.as..rotation, param2 = node.param2}) + end end, }) advtrains.trackplacer.add_worked("advtrains:signal", r, rotation, nil) @@ -130,8 +134,10 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", end end, }, - on_rightclick=function(pos, node, clicker) - advtrains.ndb.swap_node(pos, {name = "advtrains:signal_wall_"..loc.."_"..f.as, param2 = node.param2}) + on_rightclick=function(pos, node, player) + if minetest.check_player_privs(player:get_player_name(), {train_operator=true}) then + advtrains.ndb.swap_node(pos, {name = "advtrains:signal_wall_"..loc.."_"..f.as, param2 = node.param2}) + end end, }) end diff --git a/advtrains/advtrains/tracks.lua b/advtrains/advtrains/tracks.lua index 90d2ad3..2bb61eb 100644 --- a/advtrains/advtrains/tracks.lua +++ b/advtrains/advtrains/tracks.lua @@ -260,11 +260,15 @@ advtrains.trackpresets = ap }]]
function advtrains.register_tracks(tracktype, def, preset)
local function make_switchfunc(suffix_target, mesecon_state, is_state)
+ local rcswitchfunc=function(pos, node, player)
+ if minetest.check_player_privs(player:get_player_name(), {train_operator=true}) then
+ advtrains.ndb.swap_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2})
+ end
+ end
local switchfunc=function(pos, node, newstate)
if newstate~=is_state then
advtrains.ndb.swap_node(pos, {name=def.nodename_prefix.."_"..suffix_target, param2=node.param2})
end
- advtrains.invalidate_all_paths()
end
local mesec
if mesecon_state then -- if mesecons is not wanted, do not.
@@ -273,13 +277,13 @@ function advtrains.register_tracks(tracktype, def, preset) rules=advtrains.meseconrules
}}
end
- return switchfunc, mesec,
+ return rcswitchfunc, mesec,
{
getstate = is_state,
setstate = switchfunc,
}
end
- local function make_overdef(suffix, rotation, conns, switchfunc, mesecontbl, luaautomation, in_creative_inv, drop_slope)
+ local function make_overdef(suffix, rotation, conns, rcswitchfunc, mesecontbl, luaautomation, in_creative_inv, drop_slope)
local img_suffix=suffix..rotation
return {
mesh = def.shared_model or (def.models_prefix.."_"..img_suffix..def.models_suffix),
@@ -293,7 +297,7 @@ function advtrains.register_tracks(tracktype, def, preset) rely2=conns.rely2 or 0,
railheight=conns.railheight or 0,
- on_rightclick=switchfunc,
+ on_rightclick=rcswitchfunc,
groups = {
attached_node=1,
["advtrains_track_"..tracktype]=1,
@@ -352,9 +356,9 @@ function advtrains.register_tracks(tracktype, def, preset) for suffix, conns in pairs(preset.variant) do
for rotid, rotation in ipairs(preset.rotation) do
if not def.formats[suffix] or def.formats[suffix][rotid] then
- local switchfunc, mesecontbl, luaautomation
+ local rcswitchfunc, mesecontbl, luaautomation
if preset.switch[suffix] then
- switchfunc, mesecontbl, luaautomation=make_switchfunc(preset.switch[suffix]..rotation, preset.switchmc[suffix], preset.switchst[suffix])
+ rcswitchfunc, mesecontbl, luaautomation=make_switchfunc(preset.switch[suffix]..rotation, preset.switchmc[suffix], preset.switchst[suffix])
end
local adef={}
if def.get_additional_definiton then
@@ -366,7 +370,7 @@ function advtrains.register_tracks(tracktype, def, preset) make_overdef(
suffix, rotation,
cycle_conns(conns, rotid),
- switchfunc, mesecontbl, luaautomation, preset.increativeinv[suffix], preset.slopenodes[suffix]
+ rcswitchfunc, mesecontbl, luaautomation, preset.increativeinv[suffix], preset.slopenodes[suffix]
),
adef
)
diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua index 28de3fa..15a0ec7 100644 --- a/advtrains/advtrains/wagons.lua +++ b/advtrains/advtrains/wagons.lua @@ -8,6 +8,11 @@ minetest.register_privilege("train_remove", { description = "Player can remove trains not owned by player",
give_to_singleplayer= false,
});
+minetest.register_privilege("train_operator", {
+ description = "Player may operate trains and switch signals. Given by default. Revoke to prevent players from griefing automated subway systems.",
+ give_to_singleplayer= true,
+ default= true,
+});
local wagon={
collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5},
@@ -242,7 +247,8 @@ function wagon:on_step(dtime) --driver control
for seatno, seat in ipairs(self.seats) do
local driver=self.seatp[seatno] and minetest.get_player_by_name(self.seatp[seatno])
- if seat.driving_ctrl_access and driver then
+ local has_driverstand=seat.driving_ctrl_access and self.seatp[seatno] and minetest.check_player_privs(self.seatp[seatno], {train_operator=true})
+ if has_driverstand and driver then
advtrains.update_driver_hud(driver:get_player_name(), self:train(), self.wagon_flipped)
elseif driver then
--only show the inside text
@@ -253,7 +259,7 @@ function wagon:on_step(dtime) local pc=driver:get_player_control()
self.seatpc[seatno]=driver:get_player_control_bits()
- if seat.driving_ctrl_access then
+ if has_driverstand then
--regular driver stand controls
advtrains.on_control_change(pc, self:train(), self.wagon_flipped)
else
|