From 1b692b5b9a888cccb1264927f10760c3666ab152 Mon Sep 17 00:00:00 2001 From: Mikayla Fischler Date: Sat, 5 Apr 2025 21:14:33 -0400 Subject: [PATCH] #364 fail self check if using a side for both bundled and unbundled redstone --- rtu/config/check.lua | 6 ++++++ rtu/rtu.lua | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rtu/config/check.lua b/rtu/config/check.lua index 48d021f..2a77f39 100644 --- a/rtu/config/check.lua +++ b/rtu/config/check.lua @@ -137,14 +137,20 @@ local function self_check() -- check redstone configurations local ifaces = {} + local bundled_sides = {} for i = 1, #cfg.Redstone do local entry = cfg.Redstone[i] local ident = entry.side .. tri(entry.color, ":" .. rsio.color_name(entry.color), "") local dupe = util.table_contains(ifaces, ident) + local mixed = (bundled_sides[entry.side] and (entry.color == nil)) or (bundled_sides[entry.side] == false and (entry.color ~= nil)) + + local mixed_msg = util.trinary(bundled_sides[entry.side], "this side has bundled entry(s) but this entry is not bundled", "this side has non-bundled entry(s) but this entry is bundled") self.self_check_msg("> check redstone " .. ident .. " unique...", not dupe, "only one port should be set to a side/color combination") + self.self_check_msg("> check redstone " .. ident .. " bundle...", not mixed, mixed_msg .. ", which will not work") self.self_check_msg("> check redstone " .. ident .. " valid...", redstone.validate(entry), "configuration invalid, please re-configure redstone entry") + bundled_sides[entry.side] = bundled_sides[entry.side] or entry.color ~= nil table.insert(ifaces, ident) end diff --git a/rtu/rtu.lua b/rtu/rtu.lua index 9c8e38b..d7a576e 100644 --- a/rtu/rtu.lua +++ b/rtu/rtu.lua @@ -49,7 +49,7 @@ function rtu.load_config() return rtu.validate_config(config) end --- validate a RTU gateway configuration +-- validate an RTU gateway configuration ---@param cfg rtu_config function rtu.validate_config(cfg) local cfv = util.new_validator()