diff options
author | orwell96 <orwell@bleipb.de> | 2018-08-12 14:25:38 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-08-12 14:25:38 +0200 |
commit | cb56b8b49aa872642e53fc1a82cbdb546d5bfbcb (patch) | |
tree | cd11da5a2c3c1bac4c1361458ca754672abbcd30 /advtrains_interlocking/tcb_ts_ui.lua | |
parent | 6cdb47edd231da08b32b8258eaa507ff312134cd (diff) | |
download | advtrains-cb56b8b49aa872642e53fc1a82cbdb546d5bfbcb.tar.gz advtrains-cb56b8b49aa872642e53fc1a82cbdb546d5bfbcb.tar.bz2 advtrains-cb56b8b49aa872642e53fc1a82cbdb546d5bfbcb.zip |
Signal aspect handling, make default signals compatible, fix signal digging
Diffstat (limited to 'advtrains_interlocking/tcb_ts_ui.lua')
-rw-r--r-- | advtrains_interlocking/tcb_ts_ui.lua | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua index 2aa246b..ab7de34 100644 --- a/advtrains_interlocking/tcb_ts_ui.lua +++ b/advtrains_interlocking/tcb_ts_ui.lua @@ -142,7 +142,6 @@ minetest.register_on_punchnode(function(pos, node, player, pointed_thing) end end) - -- TCB Form local function mktcbformspec(tcbs, btnpref, offset, pname) @@ -457,6 +456,11 @@ function advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte) if tcbs.routeset then local rte = tcbs.routes[tcbs.routeset] + if not rte then + atwarn("Unknown route set from signal!") + tcbs.routeset = nil + return + end form = form.."label[0.5,2.5;A route is requested from this signal:]" form = form.."label[0.5,3.0;"..rte.name.."]" if tcbs.route_committed then @@ -552,6 +556,23 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end + if fields.unassign then + -- unassigning the signal from the tcbs + -- only when no route is set. + -- Routes and name remain saved, in case the player wants to reassign a new signal + if not tcbs.routeset then + local signal_pos = tcbs.signal + ildb.set_sigd_for_signal(signal_pos, nil) + tcbs.signal = nil + tcbs.aspect = nil + minetest.close_formspec(pname, formname) + minetest.chat_send_player(pname, "Signal has been unassigned. Name and routes are kept for reuse.") + return + else + minetest.chat_send_player(pname, "Please cancel route first!") + end + end + advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte) return end |