From c4bac79bf07b2d94f97893c41889d619d1ef97e0 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 30 Oct 2018 15:36:24 +0100 Subject: Do not allow static signals for routesetting --- advtrains_interlocking/tcb_ts_ui.lua | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua index c0e0d98..203e0b1 100644 --- a/advtrains_interlocking/tcb_ts_ui.lua +++ b/advtrains_interlocking/tcb_ts_ui.lua @@ -141,20 +141,25 @@ minetest.register_on_punchnode(function(pos, node, player, pointed_thing) if vector.distance(pos, sigd.p)<=50 then local is_signal = minetest.get_item_group(node.name, "advtrains_signal") >= 2 if is_signal then - local tcbs = ildb.get_tcbs(sigd) - if tcbs then - tcbs.signal = pos - if not tcbs.signal_name then - tcbs.signal_name = "Signal at "..minetest.pos_to_string(sigd.p) + local ndef = minetest.registered_nodes[node.name] + if ndef and ndef.advtrains and ndef.advtrains.set_aspect then + local tcbs = ildb.get_tcbs(sigd) + if tcbs then + tcbs.signal = pos + if not tcbs.signal_name then + tcbs.signal_name = "Signal at "..minetest.pos_to_string(sigd.p) + end + if not tcbs.routes then + tcbs.routes = {} + end + ildb.set_sigd_for_signal(pos, sigd) + minetest.chat_send_player(pname, "Configuring TCB: Successfully assigned signal.") + advtrains.interlocking.show_ip_form(pos, pname, true) + else + minetest.chat_send_player(pname, "Configuring TCB: Internal error, TCBS doesn't exist. Aborted.") end - if not tcbs.routes then - tcbs.routes = {} - end - ildb.set_sigd_for_signal(pos, sigd) - minetest.chat_send_player(pname, "Configuring TCB: Successfully assigned signal.") - advtrains.interlocking.show_ip_form(pos, pname, true) else - minetest.chat_send_player(pname, "Configuring TCB: Internal error, TCBS doesn't exist. Aborted.") + minetest.chat_send_player(pname, "Configuring TCB: Cannot use static signals for routesetting. Aborted.") end else minetest.chat_send_player(pname, "Configuring TCB: Not a compatible signal. Aborted.") -- cgit v1.2.3