diff options
-rw-r--r-- | advtrains/init.lua | 6 | ||||
-rw-r--r-- | advtrains/log.lua | 14 | ||||
-rw-r--r-- | advtrains/nodedb.lua | 2 | ||||
-rw-r--r-- | advtrains/settingtypes.txt | 6 | ||||
-rw-r--r-- | advtrains/tracks.lua | 4 | ||||
-rw-r--r-- | advtrains/wagons.lua | 11 |
6 files changed, 30 insertions, 13 deletions
diff --git a/advtrains/init.lua b/advtrains/init.lua index 57850db..d7bff4d 100644 --- a/advtrains/init.lua +++ b/advtrains/init.lua @@ -141,7 +141,8 @@ advtrains.meseconrules = {x=0, y=1, z=-1}, {x=0, y=-1, z=-1}, {x=0, y=-2, z=0}} - + +advtrains.fpath=minetest.get_worldpath().."/advtrains" dofile(advtrains.modpath.."/path.lua") dofile(advtrains.modpath.."/trainlogic.lua") @@ -160,12 +161,15 @@ dofile(advtrains.modpath.."/misc_nodes.lua") dofile(advtrains.modpath.."/crafting.lua") dofile(advtrains.modpath.."/craft_items.lua") +dofile(advtrains.modpath.."/log.lua") + if minetest.global_exists("digtron") then dofile(advtrains.modpath.."/digtron.lua") end --load/save + advtrains.fpath=minetest.get_worldpath().."/advtrains" dofile(advtrains.modpath.."/log.lua") diff --git a/advtrains/log.lua b/advtrains/log.lua index 827948f..d2b71d3 100644 --- a/advtrains/log.lua +++ b/advtrains/log.lua @@ -1,9 +1,13 @@ -- Log accesses to driver stands and changes to switches -advtrains.logfile = advtrains.fpath .. "_log" +advtrains.log = function() end -function advtrains.log (event, player, pos, data) - local log = io.open(advtrains.logfile, "a+") - log:write(os.date()..": "..event.." by "..player.." at "..minetest.pos_to_string(pos).." -- "..(data or "").."\n") - log:close() +if minetest.settings:get_bool("advtrains_enable_logging") then + advtrains.logfile = advtrains.fpath .. "_log" + + function advtrains.log (event, player, pos, data) + local log = io.open(advtrains.logfile, "a+") + log:write(os.date()..": "..event.." by "..player.." at "..minetest.pos_to_string(pos).." -- "..(data or "").."\n") + log:close() + end end diff --git a/advtrains/nodedb.lua b/advtrains/nodedb.lua index f735b79..592e730 100644 --- a/advtrains/nodedb.lua +++ b/advtrains/nodedb.lua @@ -256,7 +256,7 @@ ndb.restore_all = function() end end end - local text="Restore node database: Replaced",cnt,"nodes, removed",dcnt,"ghost nodes" + local text="Restore node database: Replaced"..cnt.."nodes, removed"..dcnt.."ghost nodes." atlog(text) return text end diff --git a/advtrains/settingtypes.txt b/advtrains/settingtypes.txt index 60f8477..d0c27ec 100644 --- a/advtrains/settingtypes.txt +++ b/advtrains/settingtypes.txt @@ -5,4 +5,8 @@ advtrains_disable_collisions (Disable train collisions) 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
\ No newline at end of file +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 diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua index 74122f2..4b2b17c 100644 --- a/advtrains/tracks.lua +++ b/advtrains/tracks.lua @@ -310,8 +310,8 @@ function advtrains.register_tracks(tracktype, def, preset) end
ndef.on_rightclick = function(pos, node, player)
if minetest.check_player_privs(player:get_player_name(), {train_operator=true}) then
- switchfunc(pos, node)
- advtrains.log("Switch", player:get_player_name(), pos)
+ switchfunc(pos, node)
+ advtrains.log("Switch", player:get_player_name(), pos)
end
end
if var.switchmc then
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua index 4e9cee5..b30c5b5 100644 --- a/advtrains/wagons.lua +++ b/advtrains/wagons.lua @@ -251,7 +251,7 @@ 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])
- local has_driverstand = self.seatp[seatno] and minetest.check_player_privs(self.seatp[seatno], {train_operator=true})
+ local has_driverstand = self.seatp[seatno] and (minetest.check_player_privs(self.seatp[seatno], {train_operator=true}) or self.owner==self.seatp[seatno])
if self.seat_groups then
has_driverstand = has_driverstand and (seat.driving_ctrl_access or self.seat_groups[seat.group].driving_ctrl_access)
else
@@ -1084,11 +1084,11 @@ function wagon:seating_from_key_helper(pname, fields, no) end
end
function wagon:check_seat_group_access(pname, sgr)
- if self.seat_groups[sgr].driving_ctrl_access and not minetest.check_player_privs(pname, "train_operator") then
+ if self.seat_groups[sgr].driving_ctrl_access and not (minetest.check_player_privs(pname, "train_operator") or self.owner==pname) then
return false, "Missing train_operator privilege."
end
if self.seat_groups[sgr].driving_ctrl_access then
- advtrains.log("Drive", pname, self.object:getpos(), self:train().text_outside)
+ advtrains.log("Drive", pname, self.object:getpos(), self:train().text_outside)
end
if not self.seat_access then
return true
@@ -1123,8 +1123,13 @@ function wagon:safe_decouple(pname) minetest.chat_send_player(pname, "Couple is locked (ask owner or admin to unlock it)")
return false
end
+<<<<<<< HEAD
advtrains.log("Discouple", pname, self.object:getpos(), self:train().text_outside)
atprint("wagon:discouple() Splitting train", selftrain_id)
+=======
+ atprint("wagon:discouple() Splitting train", self.train_id)
+ advtrains.log("Discouple", pname, self.object:getpos(), self:train().text_outside)
+>>>>>>> 481f6218a8b377a0826b7e080046b5a890702e12
advtrains.split_train_at_wagon(self)--found in trainlogic.lua
return true
end
|