From 8f8f009425a4d3341d3d00e6a537b5af320b5639 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Tue, 9 Oct 2018 11:36:34 +0200 Subject: Make signal influence point (~halt point) specifiable Also extend signal api necessarily --- advtrains/signals.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'advtrains') diff --git a/advtrains/signals.lua b/advtrains/signals.lua index 75f9213..669e825 100644 --- a/advtrains/signals.lua +++ b/advtrains/signals.lua @@ -10,6 +10,23 @@ local function can_dig_func(pos) return true end +local function aspect(b) +return { + main = { + free = b, + speed = -1, + }, + shunt = { + free = false, + }, + dst = { + free = true, + speed = -1, + }, + info = {} +} +end + for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", als="green"}}) do advtrains.trackplacer.register_tracktype("advtrains:retrosignal", "") @@ -64,6 +81,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", else advtrains.ndb.swap_node(pos, {name = "advtrains:retrosignal_off"..rotation, param2 = node.param2}, true) end + end, + get_aspect = function(pos, node) + return aspect(r=="on") end }, can_dig = can_dig_func, @@ -117,6 +137,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", advtrains.ndb.swap_node(pos, {name = "advtrains:signal_off"..rotation, param2 = node.param2}, true) end end, + get_aspect = function(pos, node) + return aspect(r=="on") + end, getstate = f.ls, setstate = function(pos, node, newstate) if newstate == f.als then @@ -180,6 +203,9 @@ for r,f in pairs({on={as="off", ls="green", als="red"}, off={as="on", ls="red", advtrains.ndb.swap_node(pos, {name = "advtrains:signal_wall_"..loc.."_off", param2 = node.param2}, true) end end, + get_aspect = function(pos, node) + return aspect(r=="on") + end, getstate = f.ls, setstate = function(pos, node, newstate) if newstate == f.als then -- cgit v1.2.3