Do not duplicate definitions of 'print' in every file

master
orwell96 2017-01-02 13:49:20 +01:00
parent 987cd5b7f0
commit 8784ee41dd
4 changed files with 9 additions and 12 deletions

View File

@ -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", {

View File

@ -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");

View File

@ -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

View File

@ -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