r/ComputerCraft • • Nov 27 '23

How to Combine and Subtract Colours in Loop

2 Upvotes
local t = {
    purple = {
        side = "left",
        flux_level = 1,
        flux_max = 7,
        output = colours.purple
    },

    lime = {
        side = "back",
        flux_level = 1,
        flux_max = 7,
        output = colours.lime
    },

    orange = {
        side = "right",
        flux_level = 1,
        flux_max = 7,
        output = colours.orange
    },

    white = {
        side = "front",
        flux_level = 1,
        flux_max = 5,
        output = colours.white
    }
}

--------------------------- 
--Emits bundled redstone when flux max is exceeded
--------------------------- 
local clr_set = {}

local c = colours.combine(clr_set)                      -- ERROR
local s = colours.subtract(clr_set)                     -- ERROR

local function stopProduction()
    for k in pairs(t) do
        if t[k].flux_level >= t[k].flux_max then
        print("STOP")
        table.insert(clr_set,t[k].output)              -- *
        rs.setBundledOutput("front",c)
        else
        sleep(0.5)
        table.remove(clr_set,t[k].output)              -- *
        rs.setBundledOutput("front", s)
        print("Good")
        end
    end
end

Tried through table, however colours api does not like it: expected number got table.

Any method how to do that?

Not related:

Is the script alright? Anything to improve so far?

https://pastebin.com/sXqSzWzc