diff options
Diffstat (limited to 'couple.lua')
-rw-r--r-- | couple.lua | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -36,10 +36,15 @@ minetest.register_entity("advtrains:discouple", { if not self.wagon then self.object:remove() end + --getyaw seems to be a reliable method to check if an object is loaded...if it returns nil, it is not. + if not self.wagon.object:getyaw() then + self.object:remove() + end 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 |