aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2017-11-24 12:07:23 +0100
committerorwell96 <orwell@bleipb.de>2017-11-24 12:07:23 +0100
commitef076d6435d188c66ad6372d219006d7725980c9 (patch)
tree89d5b67a5155dd1e1d13e9859c845ac1218e2ba9
parent3d29635a8ff605459dfbf9a95e988bd0e31cc94d (diff)
parent7ea41df5d9e269a35ffcd64b90c7a21ec8012a22 (diff)
downloadadvtrains-ef076d6435d188c66ad6372d219006d7725980c9.tar.gz
advtrains-ef076d6435d188c66ad6372d219006d7725980c9.tar.bz2
advtrains-ef076d6435d188c66ad6372d219006d7725980c9.zip
Merge branch 'master' of https://github.com/orwell96/advtrains
-rw-r--r--advtrains/wagons.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 8e3dd8d..3892813 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -477,6 +477,28 @@ function wagon:on_step(dtime)
self.object:setpos(actual_pos)
self.object:setvelocity(velocityvec)
self.object:setacceleration(accelerationvec)
+
+ if #self.seats > 0 and self.old_yaw ~= yaw then
+ if not self.player_yaw then
+ self.player_yaw = {}
+ end
+ for _,name in pairs(self.seatp) do
+ local p = minetest.get_player_by_name(name)
+ if p then
+ if not self.turning then
+ -- save player looking direction offset
+ 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]+yaw)
+ end
+ end
+ self.turning = true
+ elseif self.old_yaw == yaw then
+ -- train is no longer turning
+ self.turning = false
+ end
+
self.object:setyaw(yaw)
self.updatepct_timer=2
if self.update_animation then