diff options
author | orwell96 <orwell@bleipb.de> | 2018-04-26 23:35:19 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-06-14 17:39:42 +0200 |
commit | caf2bda7bc02f0bbe6dbbeb415e7881158d143b9 (patch) | |
tree | 6cf81bb311517b3ae1108c6533fa8f28c803ed9e /advtrains/trainlogic.lua | |
parent | 139a26fccce1e622d58f1673284e2addfb0d1ed2 (diff) | |
download | advtrains-caf2bda7bc02f0bbe6dbbeb415e7881158d143b9.tar.gz advtrains-caf2bda7bc02f0bbe6dbbeb415e7881158d143b9.tar.bz2 advtrains-caf2bda7bc02f0bbe6dbbeb415e7881158d143b9.zip |
Fix path_dir to actually be an angle, path item deletion and orientation of wagons
The occupation system as it is now will change. For each position, I will save the index in the train's path,
and implement a callback system. I need this because the occupation window system will not be enough to cover all use cases
(e.g. to make a train stop with it's center or back at a certain position, I need 3 different brake distances, which doesn't fit into the scheme)
Diffstat (limited to 'advtrains/trainlogic.lua')
-rw-r--r-- | advtrains/trainlogic.lua | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua index 12ec8b5..fa3ff9e 100644 --- a/advtrains/trainlogic.lua +++ b/advtrains/trainlogic.lua @@ -411,7 +411,7 @@ function advtrains.train_step_b(id, train, dtime) train.tarvelocity = train.velocity end else - train.last_accel = 0 + train.acceleration = 0 end --- 4. move train --- @@ -436,6 +436,7 @@ if train.no_step or train.wait_for_path then return end advtrains.path_clear_unused(train) -- Set our path restoration position + -- TODO make a common function to find a restore positionon the path, in case the wanted position is off-track local fli = atfloor(train.index) train.last_pos = advtrains.path_get(train, fli) train.last_connid = train.path_cn[fli] @@ -854,26 +855,21 @@ function advtrains.do_connect_trains(first_id, second_id, player) return true end --- TODO function advtrains.invert_train(train_id) local train=advtrains.trains[train_id] - local old_path=train.path - local old_path_dist=train.path_dist - train.path={} - train.path_dist={} - train.index, train.end_index= -train.end_index, -train.index - train.path_extent_min, train.path_extent_max = -train.path_extent_max, -train.path_extent_min - train.min_index_on_track, train.max_index_on_track = -train.max_index_on_track, -train.min_index_on_track - train.detector_old_index, train.detector_old_end_index = -train.detector_old_end_index, -train.detector_old_index - train.couple_lck_back, train.couple_lck_front = train.couple_lck_front, train.couple_lck_back - - train.velocity=-train.velocity - train.tarvelocity=-train.tarvelocity - for k,v in pairs(old_path) do - train.path[-k]=v - train.path_dist[-k-1]=old_path_dist[k] - end + advtrains.train_ensure_clean(train_id, train, 0) + -- Set the path restoration position to the opposite direction + local fli = atfloor(train.end_index) + 1 + train.last_pos = advtrains.path_get(train, fli) + train.last_connid = train.path_cp[fli] + train.last_frac = fli - train.end_index + + -- rotate some other stuff + train.couple_lck_back, train.couple_lck_front = train.couple_lck_front, train.couple_lck_back + + advtrains.path_invalidate(train) + local old_trainparts=train.trainparts train.trainparts={} for k,v in ipairs(old_trainparts) do |