aboutsummaryrefslogtreecommitdiff
path: root/advtrains/wagons.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-04-26 23:35:19 +0200
committerorwell96 <orwell@bleipb.de>2018-06-14 17:39:42 +0200
commitcaf2bda7bc02f0bbe6dbbeb415e7881158d143b9 (patch)
tree6cf81bb311517b3ae1108c6533fa8f28c803ed9e /advtrains/wagons.lua
parent139a26fccce1e622d58f1673284e2addfb0d1ed2 (diff)
downloadadvtrains-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/wagons.lua')
-rw-r--r--advtrains/wagons.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index c3217e2..bf128d9 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -185,7 +185,7 @@ function wagon:destroy()
if data.train_id and self:train() then
table.remove(self:train().trainparts, data.pos_in_trainparts)
- advtrains.update_trainpart_properties(self.train_id)
+ advtrains.update_trainpart_properties(data.train_id)
advtrains.wagons[self.id]=nil
if self.discouple then self.discouple.object:remove() end--will have no effect on unloaded objects
return true
@@ -196,6 +196,7 @@ function wagon:destroy()
self.object:remove()
end
+local pihalf = math.pi/2
function wagon:on_step(dtime)
return advtrains.pcall(function()
@@ -375,9 +376,11 @@ function wagon:on_step(dtime)
-- Calculate new position, yaw and direction vector
local index = advtrains.path_get_index_by_offset(train, train.index, -data.pos_in_train)
- local pos, yaw, npos, npos2 = advtrains.path_get_interpolated(train, index)
+ local pos, tyaw, npos, npos2 = advtrains.path_get_interpolated(train, index)
local vdir = vector.normalize(vector.subtract(npos2, npos))
+ local yaw = tyaw - pihalf
+
--automatic get_on
--needs to know index and path
if self.door_entry and train.door_open and train.door_open~=0 and train.velocity==0 then
@@ -478,7 +481,7 @@ function wagon:on_step(dtime)
self.player_yaw[name] = p:get_look_horizontal()-self.old_yaw
end
-- set player looking direction using calculated offset
- p:set_look_horizontal((self.player_yaw[name] or 0)+yaw)
+ --TODO p:set_look_horizontal((self.player_yaw[name] or 0)+yaw)
end
end
self.turning = true