diff options
author | orwell96 <orwell@bleipb.de> | 2018-10-10 22:41:59 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-10-10 22:41:59 +0200 |
commit | 842a85606e4495dd631c2916d09a760d74a0ce13 (patch) | |
tree | f28bb815ecd01681f98166578c659aef48082b2a /advtrains/occupation.lua | |
parent | 33c839b40d48e154f5b03619a9bdce1bed1fc602 (diff) | |
download | advtrains-842a85606e4495dd631c2916d09a760d74a0ce13.tar.gz advtrains-842a85606e4495dd631c2916d09a760d74a0ce13.tar.bz2 advtrains-842a85606e4495dd631c2916d09a760d74a0ce13.zip |
Properly implement invalidate_all_paths, recheck lzb on aspect change
Diffstat (limited to 'advtrains/occupation.lua')
-rw-r--r-- | advtrains/occupation.lua | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/advtrains/occupation.lua b/advtrains/occupation.lua index dd0235a..568f308 100644 --- a/advtrains/occupation.lua +++ b/advtrains/occupation.lua @@ -208,7 +208,7 @@ function o.get_occupations(train, index) return r, pos end -- Gets a mapping of train id's to indexes of trains that stand or drive over --- returns (table with train_id->index), position +-- returns (table with train_id->index) function o.get_trains_at(ppos) local pos = advtrains.round_vector_floor_y(ppos) local t = occget(pos) @@ -226,4 +226,22 @@ function o.get_trains_at(ppos) return r end +-- Gets a mapping of train id's to indexes of trains that have a path +-- generated over this node +-- returns (table with train_id->index) +function o.get_trains_over(ppos) + local pos = advtrains.round_vector_floor_y(ppos) + local t = occget(pos) + if not t then return {} end + local r = {} + local i = 1 + while t[i] do + local train = advtrains.trains[t[i]] + local idx = t[i+1] + r[t[i]] = idx + i = i + 2 + end + return r +end + advtrains.occ = o |