aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-01-22 22:42:50 +0100
committerorwell96 <orwell@bleipb.de>2018-01-22 22:44:55 +0100
commit418c026038a21ba7c7ffaff7ec9f607b594670ef (patch)
treeef6ef4b758d193921c7a5e36178c4a7c3e4f1cb0
parent8ef6e9a52924a77b7479690817d416eb2e85722f (diff)
downloadadvtrains-418c026038a21ba7c7ffaff7ec9f607b594670ef.tar.gz
advtrains-418c026038a21ba7c7ffaff7ec9f607b594670ef.tar.bz2
advtrains-418c026038a21ba7c7ffaff7ec9f607b594670ef.zip
Correct discouple position
Discouple entity was falsely placed at the position of the wagon instead of at its end
-rw-r--r--advtrains/couple.lua3
-rw-r--r--advtrains/wagons.lua10
2 files changed, 8 insertions, 5 deletions
diff --git a/advtrains/couple.lua b/advtrains/couple.lua
index 6a06077..7e99571 100644
--- a/advtrains/couple.lua
+++ b/advtrains/couple.lua
@@ -56,9 +56,6 @@ minetest.register_entity("advtrains:discouple", {
self.object:remove()
return
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)
end)
end,
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 5fd7de7..ee668ac 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -366,15 +366,20 @@ function wagon:on_step(dtime)
--DisCouple
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
- 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
local le=object:get_luaentity()
le.wagon=self
--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})
self.discouple=le
+ atprint(self.unique_id,"success")
else
atprint("Couldn't spawn DisCouple")
end
@@ -382,6 +387,7 @@ function wagon:on_step(dtime)
else
if self.discouple and self.discouple.object:getyaw() then
self.discouple.object:remove()
+ atprint(self.unique_id," removing discouple")
end
end
end