aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--couple.lua7
-rw-r--r--damage.lua5
-rw-r--r--textures/advtrains_track_cr.pngbin0 -> 33370 bytes
-rw-r--r--textures/advtrains_track_cr_45.pngbin0 -> 33938 bytes
-rw-r--r--textures/advtrains_track_placer.pngbin0 -> 32349 bytes
-rw-r--r--textures/advtrains_track_st.pngbin0 -> 20405 bytes
-rw-r--r--textures/advtrains_track_st_45.pngbin0 -> 39977 bytes
-rw-r--r--textures/advtrains_track_swl_cr.pngbin0 -> 33378 bytes
-rw-r--r--textures/advtrains_track_swl_cr_45.pngbin0 -> 45772 bytes
-rw-r--r--textures/advtrains_track_swl_st.pngbin0 -> 32321 bytes
-rw-r--r--textures/advtrains_track_swl_st_45.pngbin0 -> 46408 bytes
-rw-r--r--textures/advtrains_track_swr_cr.pngbin0 -> 33670 bytes
-rw-r--r--textures/advtrains_track_swr_cr_45.pngbin0 -> 46865 bytes
-rw-r--r--textures/advtrains_track_swr_st.pngbin0 -> 32654 bytes
-rw-r--r--textures/advtrains_track_swr_st_45.pngbin0 -> 47636 bytes
-rw-r--r--textures/advtrains_track_vert1.png (renamed from textures/track_vert1.png)bin1777 -> 1777 bytes
-rw-r--r--textures/advtrains_track_vert2.png (renamed from textures/track_vert2.png)bin2012 -> 2012 bytes
-rw-r--r--textures/larger rails.pngbin0 -> 81337 bytes
-rw-r--r--textures/larger rails.xcfbin0 -> 1239132 bytes
-rw-r--r--textures/nope/track_curve.pngbin527 -> 0 bytes
-rw-r--r--textures/nope/track_curve_45.pngbin552 -> 0 bytes
-rw-r--r--textures/nope/track_std.pngbin414 -> 0 bytes
-rw-r--r--textures/nope/track_std_45.pngbin1378 -> 0 bytes
-rw-r--r--textures/nope/track_switch_l.pngbin526 -> 0 bytes
-rw-r--r--textures/nope/track_switch_l_45.pngbin1133 -> 0 bytes
-rw-r--r--textures/nope/track_switch_r.pngbin491 -> 0 bytes
-rw-r--r--textures/nope/track_switch_r_45.pngbin1140 -> 0 bytes
-rw-r--r--textures_gravelback/advtrains_track_cr.pngbin0 -> 84648 bytes
-rw-r--r--textures_gravelback/advtrains_track_cr_45.pngbin0 -> 85734 bytes
-rw-r--r--textures_gravelback/advtrains_track_st.pngbin0 -> 67368 bytes
-rw-r--r--textures_gravelback/advtrains_track_st_45.pngbin0 -> 88782 bytes
-rw-r--r--textures_gravelback/advtrains_track_swl_cr.pngbin0 -> 83089 bytes
-rw-r--r--textures_gravelback/advtrains_track_swl_cr_45.pngbin0 -> 90284 bytes
-rw-r--r--textures_gravelback/advtrains_track_swl_st.pngbin0 -> 82548 bytes
-rw-r--r--textures_gravelback/advtrains_track_swl_st_45.pngbin0 -> 90485 bytes
-rw-r--r--textures_gravelback/advtrains_track_swr_cr.pngbin0 -> 84070 bytes
-rw-r--r--textures_gravelback/advtrains_track_swr_cr_45.pngbin0 -> 90410 bytes
-rw-r--r--textures_gravelback/advtrains_track_swr_st.pngbin0 -> 83421 bytes
-rw-r--r--textures_gravelback/advtrains_track_swr_st_45.pngbin0 -> 90641 bytes
-rw-r--r--textures_old/track_cr.png (renamed from textures/track_cr.png)bin1933 -> 1933 bytes
-rw-r--r--textures_old/track_cr_45.png (renamed from textures/track_cr_45.png)bin1945 -> 1945 bytes
-rw-r--r--textures_old/track_curve_45.xcf (renamed from textures/track_curve_45.xcf)bin13824 -> 13824 bytes
-rw-r--r--textures_old/track_placer.png (renamed from textures/track_placer.png)bin621 -> 621 bytes
-rw-r--r--textures_old/track_st.png (renamed from textures/track_st.png)bin621 -> 621 bytes
-rw-r--r--textures_old/track_st_45.png (renamed from textures/track_st_45.png)bin2549 -> 2549 bytes
-rw-r--r--textures_old/track_swl_cr.png (renamed from textures/track_swl_cr.png)bin1868 -> 1868 bytes
-rw-r--r--textures_old/track_swl_cr_45.png (renamed from textures/track_swl_cr_45.png)bin2512 -> 2512 bytes
-rw-r--r--textures_old/track_swl_st.png (renamed from textures/track_swl_st.png)bin1892 -> 1892 bytes
-rw-r--r--textures_old/track_swl_st_45.png (renamed from textures/track_swl_st_45.png)bin2509 -> 2509 bytes
-rw-r--r--textures_old/track_swr_cr.png (renamed from textures/track_swr_cr.png)bin1897 -> 1897 bytes
-rw-r--r--textures_old/track_swr_cr_45.png (renamed from textures/track_swr_cr_45.png)bin2528 -> 2528 bytes
-rw-r--r--textures_old/track_swr_st.png (renamed from textures/track_swr_st.png)bin1912 -> 1912 bytes
-rw-r--r--textures_old/track_swr_st_45.png (renamed from textures/track_swr_st_45.png)bin2485 -> 2485 bytes
-rw-r--r--tracks.lua2
-rw-r--r--trainlogic.lua4
-rw-r--r--wagons.lua58
56 files changed, 52 insertions, 24 deletions
diff --git a/couple.lua b/couple.lua
index ba4949c..eae5e1c 100644
--- a/couple.lua
+++ b/couple.lua
@@ -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
diff --git a/damage.lua b/damage.lua
index 860feaa..3fc1d97 100644
--- a/damage.lua
+++ b/damage.lua
@@ -1,5 +1,8 @@
--damage.lua
--a globalstep that damages players overrolled by trains.
+
+advtrains.player_to_wagon_mapping={}
+
local tmr=0
minetest.register_globalstep(function(dtime)
tmr=tmr-dtime
@@ -10,7 +13,7 @@ minetest.register_globalstep(function(dtime)
for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do
local le=object:get_luaentity()
if le and le.is_wagon and le.initialized and le:train() then
- if le.driver~=player and math.abs(le:train().velocity)>2 then
+ if (not advtrains.player_to_wagon_mapping[player:get_player_name()] or le.train_id~=advtrains.player_to_wagon_mapping[player:get_player_name()].train_id) and math.abs(le:train().velocity)>2 then
--player:punch(object, 1000, {damage={fleshy=3*math.abs(le:train().velocity)}})
player:set_hp(player:get_hp()-math.abs(le:train().velocity)-3)
end
diff --git a/textures/advtrains_track_cr.png b/textures/advtrains_track_cr.png
new file mode 100644
index 0000000..40f0cc5
--- /dev/null
+++ b/textures/advtrains_track_cr.png
Binary files differ
diff --git a/textures/advtrains_track_cr_45.png b/textures/advtrains_track_cr_45.png
new file mode 100644
index 0000000..54966b3
--- /dev/null
+++ b/textures/advtrains_track_cr_45.png
Binary files differ
diff --git a/textures/advtrains_track_placer.png b/textures/advtrains_track_placer.png
new file mode 100644
index 0000000..03e17ed
--- /dev/null
+++ b/textures/advtrains_track_placer.png
Binary files differ
diff --git a/textures/advtrains_track_st.png b/textures/advtrains_track_st.png
new file mode 100644
index 0000000..5ad7e4f
--- /dev/null
+++ b/textures/advtrains_track_st.png
Binary files differ
diff --git a/textures/advtrains_track_st_45.png b/textures/advtrains_track_st_45.png
new file mode 100644
index 0000000..63b4c96
--- /dev/null
+++ b/textures/advtrains_track_st_45.png
Binary files differ
diff --git a/textures/advtrains_track_swl_cr.png b/textures/advtrains_track_swl_cr.png
new file mode 100644
index 0000000..d9b5c0b
--- /dev/null
+++ b/textures/advtrains_track_swl_cr.png
Binary files differ
diff --git a/textures/advtrains_track_swl_cr_45.png b/textures/advtrains_track_swl_cr_45.png
new file mode 100644
index 0000000..f098fc9
--- /dev/null
+++ b/textures/advtrains_track_swl_cr_45.png
Binary files differ
diff --git a/textures/advtrains_track_swl_st.png b/textures/advtrains_track_swl_st.png
new file mode 100644
index 0000000..314bd2d
--- /dev/null
+++ b/textures/advtrains_track_swl_st.png
Binary files differ
diff --git a/textures/advtrains_track_swl_st_45.png b/textures/advtrains_track_swl_st_45.png
new file mode 100644
index 0000000..765d0ec
--- /dev/null
+++ b/textures/advtrains_track_swl_st_45.png
Binary files differ
diff --git a/textures/advtrains_track_swr_cr.png b/textures/advtrains_track_swr_cr.png
new file mode 100644
index 0000000..f74e1bc
--- /dev/null
+++ b/textures/advtrains_track_swr_cr.png
Binary files differ
diff --git a/textures/advtrains_track_swr_cr_45.png b/textures/advtrains_track_swr_cr_45.png
new file mode 100644
index 0000000..fa432aa
--- /dev/null
+++ b/textures/advtrains_track_swr_cr_45.png
Binary files differ
diff --git a/textures/advtrains_track_swr_st.png b/textures/advtrains_track_swr_st.png
new file mode 100644
index 0000000..06ea29e
--- /dev/null
+++ b/textures/advtrains_track_swr_st.png
Binary files differ
diff --git a/textures/advtrains_track_swr_st_45.png b/textures/advtrains_track_swr_st_45.png
new file mode 100644
index 0000000..be477b7
--- /dev/null
+++ b/textures/advtrains_track_swr_st_45.png
Binary files differ
diff --git a/textures/track_vert1.png b/textures/advtrains_track_vert1.png
index ce7c31d..ce7c31d 100644
--- a/textures/track_vert1.png
+++ b/textures/advtrains_track_vert1.png
Binary files differ
diff --git a/textures/track_vert2.png b/textures/advtrains_track_vert2.png
index 7bc7bae..7bc7bae 100644
--- a/textures/track_vert2.png
+++ b/textures/advtrains_track_vert2.png
Binary files differ
diff --git a/textures/larger rails.png b/textures/larger rails.png
new file mode 100644
index 0000000..c6c4b7f
--- /dev/null
+++ b/textures/larger rails.png
Binary files differ
diff --git a/textures/larger rails.xcf b/textures/larger rails.xcf
new file mode 100644
index 0000000..42ae592
--- /dev/null
+++ b/textures/larger rails.xcf
Binary files differ
diff --git a/textures/nope/track_curve.png b/textures/nope/track_curve.png
deleted file mode 100644
index 02bcf5c..0000000
--- a/textures/nope/track_curve.png
+++ /dev/null
Binary files differ
diff --git a/textures/nope/track_curve_45.png b/textures/nope/track_curve_45.png
deleted file mode 100644
index c69be2d..0000000
--- a/textures/nope/track_curve_45.png
+++ /dev/null
Binary files differ
diff --git a/textures/nope/track_std.png b/textures/nope/track_std.png
deleted file mode 100644
index 061949e..0000000
--- a/textures/nope/track_std.png
+++ /dev/null
Binary files differ
diff --git a/textures/nope/track_std_45.png b/textures/nope/track_std_45.png
deleted file mode 100644
index 89a1b36..0000000
--- a/textures/nope/track_std_45.png
+++ /dev/null
Binary files differ
diff --git a/textures/nope/track_switch_l.png b/textures/nope/track_switch_l.png
deleted file mode 100644
index 33ac21e..0000000
--- a/textures/nope/track_switch_l.png
+++ /dev/null
Binary files differ
diff --git a/textures/nope/track_switch_l_45.png b/textures/nope/track_switch_l_45.png
deleted file mode 100644
index d55da42..0000000
--- a/textures/nope/track_switch_l_45.png
+++ /dev/null
Binary files differ
diff --git a/textures/nope/track_switch_r.png b/textures/nope/track_switch_r.png
deleted file mode 100644
index bf2e722..0000000
--- a/textures/nope/track_switch_r.png
+++ /dev/null
Binary files differ
diff --git a/textures/nope/track_switch_r_45.png b/textures/nope/track_switch_r_45.png
deleted file mode 100644
index 5be48fd..0000000
--- a/textures/nope/track_switch_r_45.png
+++ /dev/null
Binary files differ
diff --git a/textures_gravelback/advtrains_track_cr.png b/textures_gravelback/advtrains_track_cr.png
new file mode 100644
index 0000000..a21b970
--- /dev/null
+++ b/textures_gravelback/advtrains_track_cr.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_cr_45.png b/textures_gravelback/advtrains_track_cr_45.png
new file mode 100644
index 0000000..b30a8ca
--- /dev/null
+++ b/textures_gravelback/advtrains_track_cr_45.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_st.png b/textures_gravelback/advtrains_track_st.png
new file mode 100644
index 0000000..ac94158
--- /dev/null
+++ b/textures_gravelback/advtrains_track_st.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_st_45.png b/textures_gravelback/advtrains_track_st_45.png
new file mode 100644
index 0000000..e541853
--- /dev/null
+++ b/textures_gravelback/advtrains_track_st_45.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_swl_cr.png b/textures_gravelback/advtrains_track_swl_cr.png
new file mode 100644
index 0000000..769b92d
--- /dev/null
+++ b/textures_gravelback/advtrains_track_swl_cr.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_swl_cr_45.png b/textures_gravelback/advtrains_track_swl_cr_45.png
new file mode 100644
index 0000000..6ff8b4b
--- /dev/null
+++ b/textures_gravelback/advtrains_track_swl_cr_45.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_swl_st.png b/textures_gravelback/advtrains_track_swl_st.png
new file mode 100644
index 0000000..e4d5a0c
--- /dev/null
+++ b/textures_gravelback/advtrains_track_swl_st.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_swl_st_45.png b/textures_gravelback/advtrains_track_swl_st_45.png
new file mode 100644
index 0000000..2dba2f6
--- /dev/null
+++ b/textures_gravelback/advtrains_track_swl_st_45.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_swr_cr.png b/textures_gravelback/advtrains_track_swr_cr.png
new file mode 100644
index 0000000..e13bd2e
--- /dev/null
+++ b/textures_gravelback/advtrains_track_swr_cr.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_swr_cr_45.png b/textures_gravelback/advtrains_track_swr_cr_45.png
new file mode 100644
index 0000000..e0b36ff
--- /dev/null
+++ b/textures_gravelback/advtrains_track_swr_cr_45.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_swr_st.png b/textures_gravelback/advtrains_track_swr_st.png
new file mode 100644
index 0000000..52d272d
--- /dev/null
+++ b/textures_gravelback/advtrains_track_swr_st.png
Binary files differ
diff --git a/textures_gravelback/advtrains_track_swr_st_45.png b/textures_gravelback/advtrains_track_swr_st_45.png
new file mode 100644
index 0000000..b81df2c
--- /dev/null
+++ b/textures_gravelback/advtrains_track_swr_st_45.png
Binary files differ
diff --git a/textures/track_cr.png b/textures_old/track_cr.png
index 54ddf79..54ddf79 100644
--- a/textures/track_cr.png
+++ b/textures_old/track_cr.png
Binary files differ
diff --git a/textures/track_cr_45.png b/textures_old/track_cr_45.png
index ad4580e..ad4580e 100644
--- a/textures/track_cr_45.png
+++ b/textures_old/track_cr_45.png
Binary files differ
diff --git a/textures/track_curve_45.xcf b/textures_old/track_curve_45.xcf
index 0e6c26e..0e6c26e 100644
--- a/textures/track_curve_45.xcf
+++ b/textures_old/track_curve_45.xcf
Binary files differ
diff --git a/textures/track_placer.png b/textures_old/track_placer.png
index afed4ce..afed4ce 100644
--- a/textures/track_placer.png
+++ b/textures_old/track_placer.png
Binary files differ
diff --git a/textures/track_st.png b/textures_old/track_st.png
index afed4ce..afed4ce 100644
--- a/textures/track_st.png
+++ b/textures_old/track_st.png
Binary files differ
diff --git a/textures/track_st_45.png b/textures_old/track_st_45.png
index e3ce89f..e3ce89f 100644
--- a/textures/track_st_45.png
+++ b/textures_old/track_st_45.png
Binary files differ
diff --git a/textures/track_swl_cr.png b/textures_old/track_swl_cr.png
index 602d727..602d727 100644
--- a/textures/track_swl_cr.png
+++ b/textures_old/track_swl_cr.png
Binary files differ
diff --git a/textures/track_swl_cr_45.png b/textures_old/track_swl_cr_45.png
index f3b741a..f3b741a 100644
--- a/textures/track_swl_cr_45.png
+++ b/textures_old/track_swl_cr_45.png
Binary files differ
diff --git a/textures/track_swl_st.png b/textures_old/track_swl_st.png
index b12a9ac..b12a9ac 100644
--- a/textures/track_swl_st.png
+++ b/textures_old/track_swl_st.png
Binary files differ
diff --git a/textures/track_swl_st_45.png b/textures_old/track_swl_st_45.png
index cf80d77..cf80d77 100644
--- a/textures/track_swl_st_45.png
+++ b/textures_old/track_swl_st_45.png
Binary files differ
diff --git a/textures/track_swr_cr.png b/textures_old/track_swr_cr.png
index 92a09bd..92a09bd 100644
--- a/textures/track_swr_cr.png
+++ b/textures_old/track_swr_cr.png
Binary files differ
diff --git a/textures/track_swr_cr_45.png b/textures_old/track_swr_cr_45.png
index f127e30..f127e30 100644
--- a/textures/track_swr_cr_45.png
+++ b/textures_old/track_swr_cr_45.png
Binary files differ
diff --git a/textures/track_swr_st.png b/textures_old/track_swr_st.png
index 7d014fc..7d014fc 100644
--- a/textures/track_swr_st.png
+++ b/textures_old/track_swr_st.png
Binary files differ
diff --git a/textures/track_swr_st_45.png b/textures_old/track_swr_st_45.png
index 5d7764a..5d7764a 100644
--- a/textures/track_swr_st_45.png
+++ b/textures_old/track_swr_st_45.png
Binary files differ
diff --git a/tracks.lua b/tracks.lua
index f9e4b2b..1e7788f 100644
--- a/tracks.lua
+++ b/tracks.lua
@@ -122,7 +122,7 @@ end
advtrains.register_tracks("regular", {
nodename_prefix="advtrains:track",
- texture_prefix="track",
+ texture_prefix="advtrains_track",
description="Regular Train Track",
})
diff --git a/trainlogic.lua b/trainlogic.lua
index f7a9363..7d7fe9f 100644
--- a/trainlogic.lua
+++ b/trainlogic.lua
@@ -81,6 +81,10 @@ advtrains.save = function()
else
data.driver_name=nil
end
+ if data.discouple then
+ data.discouple.object:remove()
+ data.discouple=nil
+ end
end
--print(dump(advtrains.wagon_save))
datastr = minetest.serialize(advtrains.wagon_save)
diff --git a/wagons.lua b/wagons.lua
index 69504a1..c12d62d 100644
--- a/wagons.lua
+++ b/wagons.lua
@@ -37,12 +37,15 @@ function wagon:on_rightclick(clicker)
return
end
if self.driver and clicker == self.driver then
+ advtrains.player_to_wagon_mapping[self.driver:get_player_name()]=nil
advtrains.set_trainhud(self.driver:get_player_name(), "")
self.driver = nil
+ self.driver_name = nil
clicker:set_detach()
clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
elseif not self.driver then
self.driver = clicker
+ advtrains.player_to_wagon_mapping[clicker:get_player_name()]=self
clicker:set_attach(self.object, "", self.attach_offset, {x=0,y=0,z=0})
clicker:set_eye_offset(self.view_offset, self.view_offset)
end
@@ -127,7 +130,7 @@ function wagon:on_punch(puncher, time_from_last_punch, tool_capabilities, direct
table.remove(self:train().trainparts, self.pos_in_trainparts)
advtrains.update_trainpart_properties(self.train_id)
advtrains.wagon_save[self.unique_id]=nil
- if self.discouple_id and minetest.object_refs[self.discouple_id] then minetest.object_refs[self.discouple_id]:remove() end
+ if self.discouple then self.discouple.object:remove() end--will have no effect on unloaded objects
return
@@ -156,25 +159,14 @@ function wagon:on_step(dtime)
self.initialized=true
end
- --DisCouple
- if self.pos_in_trainparts and self.pos_in_trainparts>1 then
- if not self.discouple_id or not minetest.luaentities[self.discouple_id] then
- local object=minetest.add_entity(pos, "advtrains:discouple")
- if object then
- print("spawning discouple")
- 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})
- --find in object_refs
- for aoi, compare in pairs(minetest.object_refs) do
- if compare==object then
- self.discouple_id=aoi
- end
- end
- else
- print("Couldn't spawn DisCouple")
- end
+ --re-attach driver if he got lost
+ if not self.driver and self.driver_name then
+ local clicker=minetest.get_player_by_name(self.driver_name)
+ if clicker then
+ self.driver = clicker
+ advtrains.player_to_wagon_mapping[clicker:get_player_name()]=self
+ clicker:set_attach(self.object, "", self.attach_offset, {x=0,y=0,z=0})
+ clicker:set_eye_offset(self.view_offset, self.view_offset)
end
end
@@ -190,10 +182,12 @@ function wagon:on_step(dtime)
self:train().tarvelocity=math.max(self:train().tarvelocity-1, -(advtrains.all_traintypes[self:train().traintype].max_speed or 10))
elseif pc.aux1 then --slower
if true or math.abs(self:train().velocity)<=3 then--TODO debug
+ advtrains.player_to_wagon_mapping[self.driver:get_player_name()]=nil
self.driver:set_detach()
self.driver:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0})
advtrains.set_trainhud(self.driver:get_player_name(), "")
self.driver = nil
+ self.driver_name = nil
return--(don't let it crash because of statement below)
else
minetest.chat_send_player(self.driver:get_player_name(), "Can't get off driving train!")
@@ -205,6 +199,28 @@ function wagon:on_step(dtime)
end
local gp=self:train()
+
+ --DisCouple
+ if self.pos_in_trainparts and self.pos_in_trainparts>1 then
+ if gp.velocity==0 then
+ if not self.discouple or not self.discouple.object:getyaw() then
+ local object=minetest.add_entity(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
+ else
+ print("Couldn't spawn DisCouple")
+ end
+ end
+ else
+ if self.discouple and self.discouple.object:getyaw() then
+ self.discouple.object:remove()
+ end
+ end
+ end
--for path to be available. if not, skip step
if not advtrains.get_or_create_path(self.train_id, gp) then
self.object:setvelocity({x=0, y=0, z=0})
@@ -349,7 +365,7 @@ advtrains.register_wagon("newlocomotive", "steam",{
textures = {"advtrains_newlocomotive.png"},
is_locomotive=true,
attach_offset={x=5, y=10, z=-10},
- view_offset={x=0, y=6, z=18},
+ view_offset={x=0, y=6, z=0},
visual_size = {x=1, y=1},
wagon_span=1.85,
collisionbox = {-1.0,-0.5,-1.0, 1.0,2.5,1.0},