Correct discouple position
Discouple entity was falsely placed at the position of the wagon instead of at its endmaster
parent
8ef6e9a529
commit
418c026038
|
@ -56,9 +56,6 @@ minetest.register_entity("advtrains:discouple", {
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if (self.wagon.old_velocity and self.wagon.old_velocity > 0) or self.wagon.pos_in_trainparts==1 then
|
|
||||||
self.object:remove()
|
|
||||||
end
|
|
||||||
atprintbm("discouple_step", t)
|
atprintbm("discouple_step", t)
|
||||||
end)
|
end)
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -366,15 +366,20 @@ function wagon:on_step(dtime)
|
||||||
|
|
||||||
--DisCouple
|
--DisCouple
|
||||||
if self.pos_in_trainparts and self.pos_in_trainparts>1 then
|
if self.pos_in_trainparts and self.pos_in_trainparts>1 then
|
||||||
if gp.velocity==0 then
|
if gp.velocity==0 and not self.dcpl_lock then
|
||||||
if not self.discouple or not self.discouple.object:getyaw() then
|
if not self.discouple or not self.discouple.object:getyaw() then
|
||||||
local object=minetest.add_entity(pos, "advtrains:discouple")
|
atprint(self.unique_id,"trying to spawn discouple")
|
||||||
|
local yaw = self.object:getyaw()
|
||||||
|
local flipsign=self.wagon_flipped and -1 or 1
|
||||||
|
local dcpl_pos = vector.add(pos, {y=0, x=-math.sin(yaw)*self.wagon_span*flipsign, z=math.cos(yaw)*self.wagon_span*flipsign})
|
||||||
|
local object=minetest.add_entity(dcpl_pos, "advtrains:discouple")
|
||||||
if object then
|
if object then
|
||||||
local le=object:get_luaentity()
|
local le=object:get_luaentity()
|
||||||
le.wagon=self
|
le.wagon=self
|
||||||
--box is hidden when attached, so unuseful.
|
--box is hidden when attached, so unuseful.
|
||||||
--object:set_attach(self.object, "", {x=0, y=0, z=self.wagon_span*10}, {x=0, y=0, z=0})
|
--object:set_attach(self.object, "", {x=0, y=0, z=self.wagon_span*10}, {x=0, y=0, z=0})
|
||||||
self.discouple=le
|
self.discouple=le
|
||||||
|
atprint(self.unique_id,"success")
|
||||||
else
|
else
|
||||||
atprint("Couldn't spawn DisCouple")
|
atprint("Couldn't spawn DisCouple")
|
||||||
end
|
end
|
||||||
|
@ -382,6 +387,7 @@ function wagon:on_step(dtime)
|
||||||
else
|
else
|
||||||
if self.discouple and self.discouple.object:getyaw() then
|
if self.discouple and self.discouple.object:getyaw() then
|
||||||
self.discouple.object:remove()
|
self.discouple.object:remove()
|
||||||
|
atprint(self.unique_id," removing discouple")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue