Signalling form auto-update
This commit is contained in:
parent
e7dcee1127
commit
7891c7c342
|
@ -320,6 +320,7 @@ function ilrs.update_route(sigd, tcbs, newrte, cancel)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
advtrains.interlocking.update_signal_aspect(tcbs)
|
advtrains.interlocking.update_signal_aspect(tcbs)
|
||||||
|
advtrains.interlocking.update_player_forms(sigd)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Try to re-set routes that conflicted with this point
|
-- Try to re-set routes that conflicted with this point
|
||||||
|
|
|
@ -539,6 +539,8 @@ end
|
||||||
|
|
||||||
-- textlist selection temporary storage
|
-- textlist selection temporary storage
|
||||||
local sig_pselidx = {}
|
local sig_pselidx = {}
|
||||||
|
-- Players having a signalling form open
|
||||||
|
local p_open_sig_form = {}
|
||||||
|
|
||||||
function advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte)
|
function advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte)
|
||||||
if not minetest.check_player_privs(pname, "train_operator") then
|
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
|
end
|
||||||
sig_pselidx[pname] = sel_rte
|
sig_pselidx[pname] = sel_rte
|
||||||
minetest.show_formspec(pname, "at_il_signalling_"..minetest.pos_to_string(sigd.p).."_"..sigd.s, form)
|
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
|
-- always a good idea to update the signal aspect
|
||||||
advtrains.interlocking.update_signal_aspect(tcbs)
|
advtrains.interlocking.update_signal_aspect(tcbs)
|
||||||
end
|
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)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
local pname = player:get_player_name()
|
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
|
-- independent of the formspec, clear this whenever some formspec event happens
|
||||||
local tpsi = sig_pselidx[pname]
|
local tpsi = sig_pselidx[pname]
|
||||||
sig_pselidx[pname] = nil
|
sig_pselidx[pname] = nil
|
||||||
|
p_open_sig_form[pname] = nil
|
||||||
|
|
||||||
local pts, connids = string.match(formname, "^at_il_signalling_([^_]+)_(%d)$")
|
local pts, connids = string.match(formname, "^at_il_signalling_([^_]+)_(%d)$")
|
||||||
local pos, connid
|
local pos, connid
|
||||||
|
|
Loading…
Reference in New Issue