--trainlogic.lua
--controls train entities stuff about connecting/disconnecting/colliding trains and other things
local setting_overrun_mode = minetest.settings:get("advtrains_overrun_mode")
local benchmark=false
local bm={}
local bmlt=0
local bmsteps=0
local bmstepint=200
atprintbm=function(action, ta)
if not benchmark then return end
local t=(os.clock()-ta)*1000
if not bm[action] then
bm[action]=t
else
bm[action]=bm[action]+t
end
bmlt=bmlt+t
end
function endstep()
if not benchmark then return end
bmsteps=bmsteps-1
if bmsteps<=0 then
bmsteps=bmstepint
for key, value in pairs(bm) do
minetest.chat_send_all(key.." "..(value/bmstepint).." ms avg.")
end
minetest.chat_send_all("Total time consumed by all advtrains actions per step: "..(bmlt/bmstepint).." ms avg.")
bm={}
bmlt=0
end
end
--acceleration for lever modes (trainhud.lua), per wagon
local t_accel_all={
[0] = -10,
[1] = -3,
[2] = -0.5,
|