aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/routesetting.lua1
-rw-r--r--advtrains_interlocking/tcb_ts_ui.lua12
2 files changed, 13 insertions, 0 deletions
diff --git a/advtrains_interlocking/routesetting.lua b/advtrains_interlocking/routesetting.lua
index 44f4592..f65cd06 100644
--- a/advtrains_interlocking/routesetting.lua
+++ b/advtrains_interlocking/routesetting.lua
@@ -320,6 +320,7 @@ function ilrs.update_route(sigd, tcbs, newrte, cancel)
end
end
advtrains.interlocking.update_signal_aspect(tcbs)
+ advtrains.interlocking.update_player_forms(sigd)
end
-- Try to re-set routes that conflicted with this point
diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua
index a81b12a..14e184e 100644
--- a/advtrains_interlocking/tcb_ts_ui.lua
+++ b/advtrains_interlocking/tcb_ts_ui.lua
@@ -539,6 +539,8 @@ end
-- textlist selection temporary storage
local sig_pselidx = {}
+-- Players having a signalling form open
+local p_open_sig_form = {}
function advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte)
if not minetest.check_player_privs(pname, "train_operator") then
@@ -621,11 +623,20 @@ function advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte)
end
sig_pselidx[pname] = sel_rte
minetest.show_formspec(pname, "at_il_signalling_"..minetest.pos_to_string(sigd.p).."_"..sigd.s, form)
+ p_open_sig_form[pname] = sigd
-- always a good idea to update the signal aspect
advtrains.interlocking.update_signal_aspect(tcbs)
end
+function advtrains.interlocking.update_player_forms(sigd)
+ for pname, tsigd in pairs(p_open_sig_form) do
+ if advtrains.interlocking.sigd_equal(sigd, tsigd) then
+ advtrains.interlocking.show_signalling_form(sigd, pname, nil)
+ end
+ end
+end
+
minetest.register_on_player_receive_fields(function(player, formname, fields)
local pname = player:get_player_name()
@@ -637,6 +648,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
-- independent of the formspec, clear this whenever some formspec event happens
local tpsi = sig_pselidx[pname]
sig_pselidx[pname] = nil
+ p_open_sig_form[pname] = nil
local pts, connids = string.match(formname, "^at_il_signalling_([^_]+)_(%d)$")
local pos, connid