aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking/tcb_ts_ui.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-08-12 14:25:38 +0200
committerorwell96 <orwell@bleipb.de>2018-08-12 14:25:38 +0200
commitcb56b8b49aa872642e53fc1a82cbdb546d5bfbcb (patch)
treecd11da5a2c3c1bac4c1361458ca754672abbcd30 /advtrains_interlocking/tcb_ts_ui.lua
parent6cdb47edd231da08b32b8258eaa507ff312134cd (diff)
downloadadvtrains-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.lua23
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