diff options
author | orwell96 <orwell@bleipb.de> | 2019-02-05 11:40:24 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2019-02-05 11:40:24 +0100 |
commit | 7891c7c34281f14c089b835c584afca82500967d (patch) | |
tree | b6e3cf7ec082720a58cd8b24a019de59978f719d /advtrains_interlocking/tcb_ts_ui.lua | |
parent | e7dcee11276477294fbc9d995c4db479e7e3cfd9 (diff) | |
download | advtrains-7891c7c34281f14c089b835c584afca82500967d.tar.gz advtrains-7891c7c34281f14c089b835c584afca82500967d.tar.bz2 advtrains-7891c7c34281f14c089b835c584afca82500967d.zip |
Signalling form auto-update
Diffstat (limited to 'advtrains_interlocking/tcb_ts_ui.lua')
-rw-r--r-- | advtrains_interlocking/tcb_ts_ui.lua | 12 |
1 files changed, 12 insertions, 0 deletions
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 |