diff options
author | Y. Wang <yw05@forksworld.de> | 2023-04-10 19:01:03 +0200 |
---|---|---|
committer | Y. Wang <yw05@forksworld.de> | 2023-04-10 19:01:03 +0200 |
commit | 5695a3e9ee457d8b0aa9ba03e7d73803d972a156 (patch) | |
tree | 3a0c0740e53df81f31c139d8337bb11c2facfbc4 | |
parent | 2afe8027986b2a8172d2cb47236e53e8f24b30f5 (diff) | |
download | advtrains-5695a3e9ee457d8b0aa9ba03e7d73803d972a156.tar.gz advtrains-5695a3e9ee457d8b0aa9ba03e7d73803d972a156.tar.bz2 advtrains-5695a3e9ee457d8b0aa9ba03e7d73803d972a156.zip |
Adjust default aspect to allow shunting
-rw-r--r-- | advtrains_interlocking/aspect.lua | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/advtrains_interlocking/aspect.lua b/advtrains_interlocking/aspect.lua index 6d6cb93..c7d5c81 100644 --- a/advtrains_interlocking/aspect.lua +++ b/advtrains_interlocking/aspect.lua @@ -3,7 +3,12 @@ local registered_groups = {} -local named_aspect_aspfields = {main = true, shunt = true, proceed_as_main = true} +local default_aspect = { + main = false, + dst = false, + shunt = true, + proceed_as_main = false, +} local signal_aspect = {} @@ -21,22 +26,22 @@ local signal_aspect_metatable = { return true end, __index = function(asp, field) - local method = signal_aspect[field] - if method then - return method + local val = signal_aspect[field] + if val then + return val end - if not named_aspect_aspfields[field] then + val = default_aspect[field] + if val == nil then return nil end local group = registered_groups[rawget(asp, "group")] - if not group then - return false - end - local aspdef = group.aspects[rawget(asp, "name")] - if not aspdef then - return false + if group then + local aspdef = group.aspects[rawget(asp, "name")] + if aspdef[field] ~= nil then + val = aspdef[field] + end end - return aspdef[field] or false + return val end, __tostring = function(asp) local st = {} @@ -123,7 +128,7 @@ function signal_aspect:to_group(group) self.name = nil end if not gdef then - for k in pairs(named_aspect_aspfields) do + for k in pairs(default_aspect) do rawset(self, k, self[k]) end self.group = nil @@ -224,7 +229,7 @@ local function register_group(def) end t.label = label - for k in pairs(named_aspect_aspfields) do + for _, k in pairs{"main", "dst", "shunt"} do t[k] = asp[k] end |