aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2018-02-18 22:52:57 +0100
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2018-02-18 22:52:57 +0100
commit81d637dc76317df249a4d290006975141ab1a605 (patch)
tree0c5c4b22002ee4c6c6a620c1142225706a5a6283 /advtrains
parent06cdb14f3d28780f011d842c17580c748d2020f2 (diff)
downloadadvtrains-81d637dc76317df249a4d290006975141ab1a605.tar.gz
advtrains-81d637dc76317df249a4d290006975141ab1a605.tar.bz2
advtrains-81d637dc76317df249a4d290006975141ab1a605.zip
added separate logging for railway networks
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/init.lua1
-rw-r--r--advtrains/log.lua9
-rw-r--r--advtrains/tracks.lua3
-rw-r--r--advtrains/wagons.lua4
4 files changed, 16 insertions, 1 deletions
diff --git a/advtrains/init.lua b/advtrains/init.lua
index c1940ad..57850db 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -167,6 +167,7 @@ end
--load/save
advtrains.fpath=minetest.get_worldpath().."/advtrains"
+dofile(advtrains.modpath.."/log.lua")
function advtrains.avt_load()
local file, err = io.open(advtrains.fpath, "r")
diff --git a/advtrains/log.lua b/advtrains/log.lua
new file mode 100644
index 0000000..827948f
--- /dev/null
+++ b/advtrains/log.lua
@@ -0,0 +1,9 @@
+-- Log accesses to driver stands and changes to switches
+
+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
diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua
index 6d218b1..74122f2 100644
--- a/advtrains/tracks.lua
+++ b/advtrains/tracks.lua
@@ -310,7 +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)
+ 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 fd01abd..4e9cee5 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -1087,6 +1087,9 @@ 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
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)
+ end
if not self.seat_access then
return true
end
@@ -1120,6 +1123,7 @@ function wagon:safe_decouple(pname)
minetest.chat_send_player(pname, "Couple is locked (ask owner or admin to unlock it)")
return false
end
+ advtrains.log("Discouple", pname, self.object:getpos(), self:train().text_outside)
atprint("wagon:discouple() Splitting train", selftrain_id)
advtrains.split_train_at_wagon(self)--found in trainlogic.lua
return true