aboutsummaryrefslogtreecommitdiff
path: root/advtrains/tracks.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2017-01-02 13:49:20 +0100
committerorwell96 <orwell@bleipb.de>2017-01-02 13:49:20 +0100
commit8784ee41ddac2959c4a2aca6dd1a5e7570ad741b (patch)
tree1089b3c9266f34398b8a7ed006f36ff7dfa53bc6 /advtrains/tracks.lua
parent987cd5b7f0ef86884858a107cc915f548675f2a8 (diff)
downloadadvtrains-8784ee41ddac2959c4a2aca6dd1a5e7570ad741b.tar.gz
advtrains-8784ee41ddac2959c4a2aca6dd1a5e7570ad741b.tar.bz2
advtrains-8784ee41ddac2959c4a2aca6dd1a5e7570ad741b.zip
Do not duplicate definitions of 'print' in every file
Diffstat (limited to 'advtrains/tracks.lua')
-rw-r--r--advtrains/tracks.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/advtrains/tracks.lua b/advtrains/tracks.lua
index 8bd5666..87998e9 100644
--- a/advtrains/tracks.lua
+++ b/advtrains/tracks.lua
@@ -386,7 +386,7 @@ advtrains.detector.clean_step_before = false
--The entry already being contained in advtrains.detector.on_node_restore will not trigger an on_train_enter event on the node. (when path is reset, this is saved).
function advtrains.detector.enter_node(pos, train_id)
local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos))
- --print("enterNode "..pts.." "..train_id)
+ print("enterNode "..pts.." "..sid(train_id))
if not advtrains.detector.on_node[pts] then
advtrains.detector.on_node[pts]=train_id
if advtrains.detector.on_node_restore[pts] then
@@ -394,14 +394,18 @@ function advtrains.detector.enter_node(pos, train_id)
else
advtrains.detector.call_enter_callback(advtrains.round_vector_floor_y(pos), train_id)
end
+ else
+ print(""..pts.." already occupied")
end
end
function advtrains.detector.leave_node(pos, train_id)
local pts = minetest.pos_to_string(advtrains.round_vector_floor_y(pos))
- --print("leaveNode "..pts.." "..train_id)
- if advtrains.detector.on_node[pts] then
+ print("leaveNode "..pts.." "..sid(train_id))
+ if advtrains.detector.on_node[pts] and advtrains.detector.on_node[pts]==train_id then
advtrains.detector.call_leave_callback(advtrains.round_vector_floor_y(pos), train_id)
advtrains.detector.on_node[pts]=nil
+ else
+ print(""..pts.." occupied by another train")
end
end
--called immediately before invalidating paths