From 24b0639c5f057ccb0fccc3c65be923bee1b571db Mon Sep 17 00:00:00 2001 From: orwell96 Date: Thu, 17 May 2018 21:37:01 +0200 Subject: Mainly make collisions and coupling work Missing: ATC stuff, yaw problems --- advtrains_luaautomation/atc_rail.lua | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'advtrains_luaautomation/atc_rail.lua') 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={ -- cgit v1.2.3