diff options
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r-- | advtrains_interlocking/database.lua | 1 | ||||
-rw-r--r-- | advtrains_interlocking/route_prog.lua | 9 | ||||
-rw-r--r-- | advtrains_interlocking/routesetting.lua | 15 |
3 files changed, 12 insertions, 13 deletions
diff --git a/advtrains_interlocking/database.lua b/advtrains_interlocking/database.lua index 9fdeeb0..f71d911 100644 --- a/advtrains_interlocking/database.lua +++ b/advtrains_interlocking/database.lua @@ -303,7 +303,6 @@ local function merge_ts(root_id, merge_id) track_sections[merge_id] = nil end --- TODO temporary local lntrans = { "A", "B" } local function sigd_to_string(sigd) return minetest.pos_to_string(sigd.p).." / "..lntrans[sigd.s] diff --git a/advtrains_interlocking/route_prog.lua b/advtrains_interlocking/route_prog.lua index 498df5f..f14ad60 100644 --- a/advtrains_interlocking/route_prog.lua +++ b/advtrains_interlocking/route_prog.lua @@ -282,7 +282,7 @@ minetest.register_chatcommand("at_rp_set", { params = "<name>", -- Short parameter description description = "Completes route programming procedure", -- Full description - privs = {interlocking = true}, -- TODO + privs = {interlocking = true}, func = function(pname, param) return advtrains.pcall(function() if param=="" then @@ -315,7 +315,7 @@ minetest.register_chatcommand("at_rp_back", { params = "", -- Short parameter description description = "Remove last route segment", -- Full description - privs = {interlocking = true}, -- Require the "privs" privilege to run + privs = {interlocking = true}, func = function(pname, param) return advtrains.pcall(function() local rp = player_rte_prog[pname] @@ -336,7 +336,7 @@ minetest.register_chatcommand("at_rp_mark", { params = "", -- Short parameter description description = "Re-set route programming markers", -- Full description - privs = {interlocking = true}, -- TODO + privs = {interlocking = true}, func = function(pname, param) return advtrains.pcall(function() local rp = player_rte_prog[pname] @@ -352,7 +352,7 @@ minetest.register_chatcommand("at_rp_discard", { params = "", -- Short parameter description description = "Discards the currently programmed route", -- Full description - privs = {interlocking = true}, -- Require the "privs" privilege to run + privs = {interlocking = true}, func = function(pname, param) return advtrains.pcall(function() player_rte_prog[pname] = nil @@ -365,5 +365,4 @@ minetest.register_chatcommand("at_rp_discard", --TODO on route setting -- unify luaautomation get/setstate interface to the core --- privileges for route programming -- routes should end at signals. complete route setting by punching a signal, and command as exceptional route completion 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) |