From 09838252fe11672d89eb00d1da13b15a293ad230 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Mon, 18 Dec 2017 23:20:29 +0100 Subject: Do not spam the server chat with messages from /at_sync_ndb and trains going off_track The off-track warning has moved into the info text of wagons --- advtrains/nodedb.lua | 17 +++++++++++------ advtrains/trainlogic.lua | 10 +++++----- advtrains/wagons.lua | 9 +++++++++ 3 files changed, 25 insertions(+), 11 deletions(-) (limited to 'advtrains') diff --git a/advtrains/nodedb.lua b/advtrains/nodedb.lua index 763edbc..a4fbf0a 100644 --- a/advtrains/nodedb.lua +++ b/advtrains/nodedb.lua @@ -233,8 +233,9 @@ minetest.register_lbm({ --used when restoring stuff after a crash ndb.restore_all = function() - atwarn("Updating the map from the nodedb, this may take a while") + --atlog("Updating the map from the nodedb, this may take a while") local cnt=0 + local dcnt=0 for y, ny in pairs(ndb_nodes) do for x, nx in pairs(ny) do for z, _ in pairs(nx) do @@ -246,17 +247,21 @@ ndb.restore_all = function() if ori_ndef and ori_ndef.groups.save_in_at_nodedb then --check if this node has been worldedited, and don't replace then if (ndbnode.name~=node.name or ndbnode.param2~=node.param2) then minetest.swap_node(pos, ndbnode) - atwarn("Replaced",node.name,"@",pos,"with",ndbnode.name) + --atlog("Replaced",node.name,"@",pos,"with",ndbnode.name) + cnt=cnt+1 end else ndb.clear(pos) - atwarn("Found ghost node (former",ndbnode and ndbnode.name,") @",pos,"deleting") + dcnt=dcnt+1 + --atlog("Found ghost node (former",ndbnode and ndbnode.name,") @",pos,"deleting") end end end end end - atwarn("Updated",cnt,"nodes") + local text="Restore node database: Replaced",cnt,"nodes, removed",dcnt,"ghost nodes" + atlog(text) + return text end minetest.register_on_dignode(function(pos, oldnode, digger) @@ -287,9 +292,9 @@ minetest.register_chatcommand("at_sync_ndb", if not minetest.check_player_privs(name, {server=true}) and os.time() < ptime+30 then return false, "Please wait at least 30s from the previous execution of /at_restore_ndb!" end - ndb.restore_all() + local text = ndb.restore_all() ptime=os.time() - return true + return true, text end) end, privs = {train_operator=true}, -- Require the "privs" privilege to run diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 76b0d1d..d98c9e8 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -252,29 +252,29 @@ function advtrains.train_step_a(id, train, dtime) if front_off_track and back_off_track then--allow movement in both directions if train.tarvelocity>1 then train.tarvelocity=1 - atwarn("Train",t_info,"is off track at both ends. Clipping velocity to 1") + atprint("Train",t_info,"is off track at both ends. Clipping velocity to 1") pprint=true end elseif front_off_track then--allow movement only backward if train.movedir==1 and train.tarvelocity>0 then train.tarvelocity=0 - atwarn("Train",t_info,"is off track. Trying to drive further out. Velocity clipped to 0") + atprint("Train",t_info,"is off track. Trying to drive further out. Velocity clipped to 0") pprint=true end if train.movedir==-1 and train.tarvelocity>1 then train.tarvelocity=1 - atwarn("Train",t_info,"is off track. Velocity clipped to 1") + atprint("Train",t_info,"is off track. Velocity clipped to 1") pprint=true end elseif back_off_track then--allow movement only forward if train.movedir==-1 and train.tarvelocity>0 then train.tarvelocity=0 - atwarn("Train",t_info,"is off track. Trying to drive further out. Velocity clipped to 0") + atprint("Train",t_info,"is off track. Trying to drive further out. Velocity clipped to 0") pprint=true end if train.movedir==1 and train.tarvelocity>1 then train.tarvelocity=1 - atwarn("Train",t_info,"is off track. Velocity clipped to 1") + atprint("Train",t_info,"is off track. Velocity clipped to 1") pprint=true end end diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua index cc1f003..415665e 100644 --- a/advtrains/wagons.lua +++ b/advtrains/wagons.lua @@ -300,6 +300,15 @@ function wagon:on_step(dtime) --check infotext local outside=self:train().text_outside or "" + + local train = self:train() + --show off-track information in outside text instead of notifying the whole server about this + local front_off_track=train.max_index_on_track and train.index and train.index>train.max_index_on_track + local back_off_track=train.min_index_on_track and train.end_index and train.end_index