diff options
Diffstat (limited to 'advtrains')
-rw-r--r-- | advtrains/advtrains/couple.lua | 6 | ||||
-rw-r--r-- | advtrains/advtrains/debugringbuffer.lua | 6 | ||||
-rw-r--r-- | advtrains/advtrains/init.lua | 9 | ||||
-rw-r--r-- | advtrains/advtrains/trainlogic.lua | 13 | ||||
-rw-r--r-- | advtrains/advtrains/wagons.lua | 4 |
5 files changed, 26 insertions, 12 deletions
diff --git a/advtrains/advtrains/couple.lua b/advtrains/advtrains/couple.lua index ac4dfce..7bab241 100644 --- a/advtrains/advtrains/couple.lua +++ b/advtrains/advtrains/couple.lua @@ -138,6 +138,8 @@ minetest.register_entity("advtrains:couple", { end, on_step=function(self, dtime) return advtrains.pcall(function() + advtrains.atprint_context_tid=sid(self.train_id_1) + advtrains.atprint_context_tid_full=self.train_id_1 local t=os.clock() if not self.train_id_1 or not self.train_id_2 then atprint("Couple: train ids not set!") self.object:remove() return end local train1=advtrains.trains[self.train_id_1] @@ -165,7 +167,7 @@ minetest.register_entity("advtrains:couple", { tp2=advtrains.get_real_index_position(train2.path, train2.end_index) end if not tp1 or not tp2 or not (vector.distance(tp1,tp2)<couple_max_dist) then - atprint("Couple: train end positions too distanced, destroying") + atprint("Couple: train end positions too distanced, destroying (distance is",vector.distance(tp1,tp2),")") self.object:remove() return else @@ -175,6 +177,8 @@ minetest.register_entity("advtrains:couple", { end end atprintbm("couple step", t) + advtrains.atprint_context_tid=nil + advtrains.atprint_context_tid_full=nil end) end, }) diff --git a/advtrains/advtrains/debugringbuffer.lua b/advtrains/advtrains/debugringbuffer.lua index 1be9da9..704c0c5 100644 --- a/advtrains/advtrains/debugringbuffer.lua +++ b/advtrains/advtrains/debugringbuffer.lua @@ -17,14 +17,14 @@ function advtrains.drb_record(tid, msg) end end function advtrains.drb_dump(tid) - atlog("Debug ring buffer output for '"..tid.."':") + atdebug("Debug ring buffer output for '"..tid.."':") local stopcnt=ringbufcnt[tid] if not stopcnt then - atlog("ID unknown!") + atdebug("ID unknown!") return end repeat - atlog(ringbufs[tid][ringbufcnt[tid]]) + atdebug(ringbufs[tid][ringbufcnt[tid]]) ringbufcnt[tid]=ringbufcnt[tid]+1 if ringbufcnt[tid] > ringbuflen then ringbufcnt[tid]=0 diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua index 26dbd8c..6713343 100644 --- a/advtrains/advtrains/init.lua +++ b/advtrains/advtrains/init.lua @@ -86,10 +86,13 @@ atprint=function(t, ...) advtrains.drb_record(context, text) end atlog=function(t, ...) - local context=advtrains.atprint_context_tid - if not context then return end local text=advtrains.print_concat_table({t, ...}) - minetest.log("action", text) + minetest.log("action", "[advtrains]"..text) +end +atdebug=function(t, ...) + local text=advtrains.print_concat_table({t, ...}) + minetest.log("action", "[advtrains]"..text) + minetest.chat_send_all("[advtrains]"..text) end atwarn=function(t, ...) local text=advtrains.print_concat_table({t, ...}) diff --git a/advtrains/advtrains/trainlogic.lua b/advtrains/advtrains/trainlogic.lua index c4df656..e3581ba 100644 --- a/advtrains/advtrains/trainlogic.lua +++ b/advtrains/advtrains/trainlogic.lua @@ -134,7 +134,7 @@ train step structure: ]] function advtrains.train_step_a(id, train, dtime) - atprint("--- runcnt ",advtrains.mainloop_runcnt,": index",train.index,"end_index", train.end_index,"| max_iot", train.max_index_on_track, "min_iot", train.min_index_on_track, "<> pe_min", train.path_extent_min,"pe_max", train.path_extent_max) + --atprint("--- runcnt ",advtrains.mainloop_runcnt,": index",train.index,"end_index", train.end_index,"| max_iot", train.max_index_on_track, "min_iot", train.min_index_on_track, "<> pe_min", train.path_extent_min,"pe_max", train.path_extent_max) if train.min_index_on_track then assert(math.floor(train.min_index_on_track)==train.min_index_on_track) end @@ -410,7 +410,10 @@ function advtrains.train_step_a(id, train, dtime) else for i=ibn, ifn do if path[i] then - advtrains.detector.stay_node(path[i], id) + local pts=minetest.pos_to_string(path[i]) + if not (advtrains.detector.on_node[pts] and advtrains.detector.on_node[pts]~=id) then + advtrains.detector.stay_node(path[i], id) + end end end @@ -420,8 +423,10 @@ function advtrains.train_step_a(id, train, dtime) local pts=minetest.pos_to_string(path[i]) if advtrains.detector.on_node[pts] and advtrains.detector.on_node[pts]~=id then --if another train has signed up for this position first, it won't be recognized in train_step_b. So do collision here. + atprint("Collision detected in enter_node callbacks (front) @",pts,"with",sid(advtrains.detector.on_node[pts])) advtrains.collide_and_spawn_couple(id, path[i], advtrains.detector.on_node[pts], false) end + atprint("enter_node (front) @index",i,"@",pts,"on_node",sid(advtrains.detector.on_node[pts])) advtrains.detector.enter_node(path[i], id) end end @@ -438,8 +443,10 @@ function advtrains.train_step_a(id, train, dtime) local pts=minetest.pos_to_string(path[i]) if advtrains.detector.on_node[pts] and advtrains.detector.on_node[pts]~=id then --if another train has signed up for this position first, it won't be recognized in train_step_b. So do collision here. - advtrains.collide_and_spawn_couple(id, path[i], advtrains.detector.on_node[pts], false) + atprint("Collision detected in enter_node callbacks (back) @",pts,"on_node",sid(advtrains.detector.on_node[pts])) + advtrains.collide_and_spawn_couple(id, path[i], advtrains.detector.on_node[pts], true) end + atprint("enter_node (back) @index",i,"@",pts,"with",sid(advtrains.detector.on_node[pts])) advtrains.detector.enter_node(path[i], id) end end diff --git a/advtrains/advtrains/wagons.lua b/advtrains/advtrains/wagons.lua index 3eabd2f..3cb34a7 100644 --- a/advtrains/advtrains/wagons.lua +++ b/advtrains/advtrains/wagons.lua @@ -285,8 +285,8 @@ function wagon:on_step(dtime) --check infotext
local outside=self:train().text_outside or ""
- if self.object:get_properties().infotext~=outside then
- self.object:set_properties({infotext=sid(self.train_id)})
+ if self.object:get_properties().infotext==outside then
+ self.object:set_properties({infotext=outside})
end
local gp=self:train()
|