aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking/routesetting.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-08-16 19:18:03 +0200
committerorwell96 <orwell@bleipb.de>2018-08-16 19:18:03 +0200
commit05cb6090ac9537650a900b64768bf3ed959cebed (patch)
tree11b7e3ab4bb846ab069fc10832b07cb36d6eb6dd /advtrains_interlocking/routesetting.lua
parent5fad61e9c981115a183527ffe58a7bbe26fea4e7 (diff)
downloadadvtrains-05cb6090ac9537650a900b64768bf3ed959cebed.tar.gz
advtrains-05cb6090ac9537650a900b64768bf3ed959cebed.tar.bz2
advtrains-05cb6090ac9537650a900b64768bf3ed959cebed.zip
Move passive API to the advtrains core
to remove dependency of interlocking on luaautomation
Diffstat (limited to 'advtrains_interlocking/routesetting.lua')
-rw-r--r--advtrains_interlocking/routesetting.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua
index 5947555..4e32b10 100644
--- a/advtrains_interlocking/routesetting.lua
+++ b/advtrains_interlocking/routesetting.lua
@@ -73,18 +73,15 @@ function ilrs.set_route(signal, route, try)
local confl = ilrs.has_route_lock(pts, state)
local pos = minetest.string_to_pos(pts)
- local node = advtrains.ndb.get_node(pos)
- local ndef = minetest.registered_nodes[node.name]
- if ndef and ndef.luaautomation and ndef.luaautomation.setstate and ndef.luaautomation.getstate then
- local cstate = ndef.luaautomation.getstate
- if type(cstate)=="function" then cstate = cstate(pos) end
+ if advtrains.is_passive(pos) then
+ local cstate = advtrains.getstate(pos)
if cstate ~= state then
local confl = ilrs.has_route_lock(pts)
if confl then
if not try then atwarn("Encountered route lock while a real run of routesetting routine, at position",pts,"while setting route",rtename,"of",signal) end
return false, "Lock conflict at "..pts..", Held locked by:\n"..confl, nil, pts
elseif not try then
- ndef.luaautomation.setstate(pos, node, state)
+ advtrains.setstate(pos, state)
end
end
if not try then
@@ -188,7 +185,11 @@ end
-- frees all route locks, even manual ones set with the tool, at a specific position
function ilrs.remove_route_locks(pts, nocallbacks)
ilrs.rte_locks[pts] = nil
- --TODO callbacks
+ -- This must be delayed, because this code is executed in-between a train step
+ -- TODO use luaautomation timers?
+ if not nocallbacks then
+ minetest.after(0, ilrs.update_waiting, "lck", pts)
+ end
end
local function sigd_equal(sigd, cmp)