aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains/couple.lua1
-rw-r--r--advtrains/init.lua6
-rw-r--r--advtrains/tracks.lua10
-rw-r--r--advtrains/trainlogic.lua4
4 files changed, 9 insertions, 12 deletions
diff --git a/advtrains/couple.lua b/advtrains/couple.lua
index 675bed5..1cfe29c 100644
--- a/advtrains/couple.lua
+++ b/advtrains/couple.lua
@@ -9,7 +9,6 @@ wagon
wagons keep their couple entity minetest-internal id inside the field discouple_id. if it refers to nowhere, they will spawn a new one if player is near
]]
-local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end
minetest.register_entity("advtrains:discouple", {
diff --git a/advtrains/init.lua b/advtrains/init.lua
index 41b624e..33aa962 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -4,10 +4,8 @@ advtrains={}
advtrains.modpath = minetest.get_modpath("advtrains")
---print=function(text)
--- minetest.log("action", tostring(text) or "<non-string>")
---end
-print = function(t) minetest.log("action", t) minetest.chat_send_all(t) end
+print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end
+sid=function(id) return string.sub(id, -4) end
dofile(advtrains.modpath.."/helpers.lua");
dofile(advtrains.modpath.."/debugitems.lua");
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
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 1050d62..9c93d96 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -1,12 +1,8 @@
--trainlogic.lua
--controls train entities stuff about connecting/disconnecting/colliding trains and other things
-local print=function(t, ...) minetest.log("action", table.concat({t, ...}, " ")) minetest.chat_send_all(table.concat({t, ...}, " ")) end
-local sid=function(id) return string.sub(id, -4) end
---local print=function() end
local benchmark=false
---printbm=function(str, t) print("[advtrains]"..str.." "..((os.clock()-t)*1000).."ms") end
local bm={}
local bmlt=0
local bmsteps=0