aboutsummaryrefslogtreecommitdiff
path: root/advtrains/helpers.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2016-12-22 18:55:10 +0100
committerorwell96 <mono96.mml@gmail.com>2016-12-22 18:55:10 +0100
commitd08e202346192c50072450a3eaa3b28cad852b84 (patch)
treefcb449a63df2c21178fba742d2121cb98c0ff6ab /advtrains/helpers.lua
parentf806ed9eee8c13eb0b4868641311d25257c63f46 (diff)
downloadadvtrains-d08e202346192c50072450a3eaa3b28cad852b84.tar.gz
advtrains-d08e202346192c50072450a3eaa3b28cad852b84.tar.bz2
advtrains-d08e202346192c50072450a3eaa3b28cad852b84.zip
remove train type concept and calculate train's capabilities based on used wagons
Diffstat (limited to 'advtrains/helpers.lua')
-rw-r--r--advtrains/helpers.lua13
1 files changed, 6 insertions, 7 deletions
diff --git a/advtrains/helpers.lua b/advtrains/helpers.lua
index 6a8175f..1a02621 100644
--- a/advtrains/helpers.lua
+++ b/advtrains/helpers.lua
@@ -55,15 +55,14 @@ rely1, rely2 tell to which height the connections are pointed to. 1 means it wil
]]
-function advtrains.conway(midreal, prev, traintype)--in order prev,mid,return
+function advtrains.conway(midreal, prev, drives_on)--in order prev,mid,return
local mid=advtrains.round_vector_floor_y(midreal)
- local drives_on=advtrains.all_traintypes[traintype].drives_on
- if not advtrains.get_rail_info_at(advtrains.round_vector_floor_y(prev), traintype) then
+ if not advtrains.get_rail_info_at(advtrains.round_vector_floor_y(prev), drives_on) then
return nil
end
- local midnode_ok, middir1, middir2, midrely1, midrely2=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(mid), traintype)
+ local midnode_ok, middir1, middir2, midrely1, midrely2=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(mid), drives_on)
if not midnode_ok then
return nil
end
@@ -104,7 +103,7 @@ function advtrains.conway(midreal, prev, traintype)--in order prev,mid,return
return nil
end
- local nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype)
+ local nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on)
--is it a rail?
if(not nextnode_ok) then
@@ -112,7 +111,7 @@ function advtrains.conway(midreal, prev, traintype)--in order prev,mid,return
next.y=next.y-1
y_offset=y_offset-1
- nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype)
+ nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on)
if(not nextnode_ok) then
--print("[advtrains]in conway: one below "..minetest.pos_to_string(next).." is not a rail either, returning!")
return nil
@@ -125,7 +124,7 @@ function advtrains.conway(midreal, prev, traintype)--in order prev,mid,return
next.y=next.y-1
y_offset=y_offset-1
- nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), traintype)
+ nextnode_ok, nextdir1, nextdir2, nextrely1, nextrely2, nextrailheight=advtrains.get_rail_info_at(advtrains.round_vector_floor_y(next), drives_on)
if(not nextnode_ok) then
--print("[advtrains]in conway: (at connecting if check again) one below "..minetest.pos_to_string(next).." is not a rail either, returning!")
return nil