diff options
author | orwell96 <orwell@bleipb.de> | 2018-08-24 09:58:23 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-08-24 09:58:23 +0200 |
commit | a71041b66b0518625083560a4acb7f38bbc18148 (patch) | |
tree | 38d2ef38712c4b3388688027aa82510665d1fd03 | |
parent | a6a042fdc40cf2d2f29062e8a068b074619faefd (diff) | |
download | advtrains-a71041b66b0518625083560a4acb7f38bbc18148.tar.gz advtrains-a71041b66b0518625083560a4acb7f38bbc18148.tar.bz2 advtrains-a71041b66b0518625083560a4acb7f38bbc18148.zip |
Fix teleporting player to train
The previous commit did the teleporting in the wrong place, causing the teleports to be sent as many times as there are trains in the world
A similar commit is included in the tss branch, there it is included in one single commit
-rw-r--r-- | advtrains/trainlogic.lua | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index f2ed831..c3fbe4a 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -46,6 +46,8 @@ local t_accel_eng={ [4] = 1.5, } +local tptimer = 0 + advtrains.mainloop_trainlogic=function(dtime) --build a table of all players indexed by pts. used by damage and door system. advtrains.playersbypts={} @@ -55,6 +57,14 @@ advtrains.mainloop_trainlogic=function(dtime) local ptspos=minetest.pos_to_string(vector.round(player:getpos())) advtrains.playersbypts[ptspos]=player end + + if tptimer<=0 then + -- teleport players to their train + advtrains.tp_player_to_train(player) + tptimer = 2 + else + tptimer = tptimer - dtime + end end --regular train step -- do in two steps: @@ -430,12 +440,6 @@ function advtrains.train_step_a(id, train, dtime) train.check_trainpartload=(train.check_trainpartload or 0)-dtime local node_range=(math.max((minetest.settings:get("active_block_range") or 0),1)*16) if train.check_trainpartload<=0 then - -- teleport players to their train - for _, player in pairs(minetest.get_connected_players()) do - advtrains.tp_player_to_train(player) - end - - local ori_pos=train_pos --see 3a. --atprint("[train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) |