aboutsummaryrefslogtreecommitdiff
path: root/couple.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2016-06-09 21:50:11 +0200
committerorwell96 <mono96.mml@gmail.com>2016-06-09 21:50:11 +0200
commit77de1965f95924ffc9086786bcb22ec02d9a8e19 (patch)
tree96779f349b3d7ca7dc0565a0a67cafd4dcb537e8 /couple.lua
parent14a71703321cd9d817275cb976fba10a0d6b4386 (diff)
downloadadvtrains-77de1965f95924ffc9086786bcb22ec02d9a8e19.tar.gz
advtrains-77de1965f95924ffc9086786bcb22ec02d9a8e19.tar.bz2
advtrains-77de1965f95924ffc9086786bcb22ec02d9a8e19.zip
fix discouple appearing on wrong side on flipped wagons, and show discouples only when train stands
Diffstat (limited to 'couple.lua')
-rw-r--r--couple.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/couple.lua b/couple.lua
index ba4949c..9f5cc83 100644
--- a/couple.lua
+++ b/couple.lua
@@ -39,7 +39,8 @@ minetest.register_entity("advtrains:discouple", {
local velocityvec=self.wagon.object:getvelocity()
self.updatepct_timer=(self.updatepct_timer or 0)-dtime
if not self.old_velocity_vector or not vector.equals(velocityvec, self.old_velocity_vector) or self.updatepct_timer<=0 then--only send update packet if something changed
- self.object:setpos(vector.add(self.wagon.object:getpos(), {y=0, x=-math.sin(self.wagon.object:getyaw())*self.wagon.wagon_span, z=math.cos(self.wagon.object:getyaw())*self.wagon.wagon_span}))
+ local flipsign=self.wagon.wagon_flipped and -1 or 1
+ self.object:setpos(vector.add(self.wagon.object:getpos(), {y=0, x=-math.sin(self.wagon.object:getyaw())*self.wagon.wagon_span*flipsign, z=math.cos(self.wagon.object:getyaw())*self.wagon.wagon_span*flipsign}))
self.object:setvelocity(velocityvec)
self.updatepct_timer=2
end