diff options
author | Blockhead <jbis1337@hotmail.com> | 2021-03-22 10:46:31 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2021-03-22 10:51:03 +0100 |
commit | 7e94650b8db63d5bbb93a539657337d323c98e3c (patch) | |
tree | 73c995d22c481a166d157339003df07a325b1416 /advtrains/signals.lua | |
parent | a224027b1687b9a56a8daf7aabaad536d1537754 (diff) | |
download | advtrains-7e94650b8db63d5bbb93a539657337d323c98e3c.tar.gz advtrains-7e94650b8db63d5bbb93a539657337d323c98e3c.tar.bz2 advtrains-7e94650b8db63d5bbb93a539657337d323c98e3c.zip |
Do not crash when operating signals without interlocking
The default set of signals were crashing when operated by right-clicking or
mesecons when advtrains_interlocking was not enabled.
Diffstat (limited to 'advtrains/signals.lua')
-rw-r--r-- | advtrains/signals.lua | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/advtrains/signals.lua b/advtrains/signals.lua index 59612cd..5fb1d1b 100644 --- a/advtrains/signals.lua +++ b/advtrains/signals.lua @@ -73,7 +73,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", rules=advtrains.meseconrules, ["action_"..f.as] = function (pos, node) advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_"..f.as..rotation, param2 = node.param2}, true) - advtrains.interlocking.signal_on_aspect_changed(pos) + if advtrains.interlocking then + advtrains.interlocking.signal_on_aspect_changed(pos) + end end }}, on_rightclick=function(pos, node, player) @@ -85,7 +87,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", advtrains.interlocking.show_ip_form(pos, pname) elseif advtrains.check_turnout_signal_protection(pos, player:get_player_name()) then advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_"..f.as..rotation, param2 = node.param2}, true) - advtrains.interlocking.signal_on_aspect_changed(pos) + if advtrains.interlocking then + advtrains.interlocking.signal_on_aspect_changed(pos) + end end end, -- new signal API @@ -134,7 +138,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", rules=advtrains.meseconrules, ["action_"..f.as] = function (pos, node) advtrains.setstate(pos, f.als, node) - advtrains.interlocking.signal_on_aspect_changed(pos) + if advtrains.interlocking then + advtrains.interlocking.signal_on_aspect_changed(pos) + end end }}, on_rightclick=function(pos, node, player) @@ -146,7 +152,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", advtrains.interlocking.show_ip_form(pos, pname) elseif advtrains.check_turnout_signal_protection(pos, player:get_player_name()) then advtrains.setstate(pos, f.als, node) - advtrains.interlocking.signal_on_aspect_changed(pos) + if advtrains.interlocking then + advtrains.interlocking.signal_on_aspect_changed(pos) + end end end, -- new signal API @@ -206,6 +214,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", rules = mrules_wallsignal, ["action_"..f.as] = function (pos, node) advtrains.setstate(pos, f.als, node) + if advtrains.interlocking then + advtrains.interlocking.signal_on_aspect_changed(pos) + end end }}, on_rightclick=function(pos, node, player) @@ -217,6 +228,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", advtrains.interlocking.show_ip_form(pos, pname) elseif advtrains.check_turnout_signal_protection(pos, player:get_player_name()) then advtrains.setstate(pos, f.als, node) + if advtrains.interlocking then + advtrains.interlocking.signal_on_aspect_changed(pos) + end end end, -- new signal API |