aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-05-17 21:37:01 +0200
committerorwell96 <orwell@bleipb.de>2018-06-14 17:39:42 +0200
commit24b0639c5f057ccb0fccc3c65be923bee1b571db (patch)
treebe7ece8c6c70701dc02ee68cf86998f310efd2ec /advtrains_luaautomation
parent5dca1553333b8267de72ebf8788afbb928251ebf (diff)
downloadadvtrains-24b0639c5f057ccb0fccc3c65be923bee1b571db.tar.gz
advtrains-24b0639c5f057ccb0fccc3c65be923bee1b571db.tar.bz2
advtrains-24b0639c5f057ccb0fccc3c65be923bee1b571db.zip
Mainly make collisions and coupling work
Missing: ATC stuff, yaw problems
Diffstat (limited to 'advtrains_luaautomation')
-rw-r--r--advtrains_luaautomation/atc_rail.lua23
1 files changed, 10 insertions, 13 deletions
diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua
index 88c9ee9..d001d88 100644
--- a/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains_luaautomation/atc_rail.lua
@@ -24,7 +24,7 @@ function r.fire_event(pos, evtdata)
--prepare ingame API for ATC. Regenerate each time since pos needs to be known
--If no train, then return false.
- local train_id=advtrains.detector.get(pos)
+ local train_id=advtrains.get_train_at_pos(pos)
local train, atc_arrow, tvel
if train_id then train=advtrains.trains[train_id] end
if train then
@@ -34,19 +34,16 @@ function r.fire_event(pos, evtdata)
atlatc.interrupt.add(0,pos,evtdata)
return
end
- for index, ppos in pairs(train.path) do
- if vector.equals(advtrains.round_vector_floor_y(ppos), pos) then
- atc_arrow =
- vector.equals(
- advtrains.dirCoordSet(pos, arrowconn),
- advtrains.round_vector_floor_y(train.path[index+train.movedir])
- )
- end
- end
- if atc_arrow==nil then
- atwarn("LuaAutomation ATC rail at", pos, ": Rail not on train's path! Can't determine arrow direction. Assuming +!")
- atc_arrow=true
+ local index = advtrains.path_lookup(train, pos)
+
+ local iconnid = 1
+ if index then
+ iconnid = train.path_cn[index]
+ else
+ atwarn("ATC rail at", pos, ": Rail not on train's path! Can't determine arrow direction. Assuming +!")
end
+ atc_arrow = iconnid == 1
+
tvel=train.velocity
end
local customfct={