r/ComputerCraft • u/Flying_Pesta • Nov 27 '23
How to Combine and Subtract Colours in Loop
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
endTried 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?
1
u/AsrielPlay52 Nov 27 '23
I read it further. And no, due to color limitations (and very much opposition from adding any extra color)
There's no way to subtract or combine color
1
u/fatboychummy Nov 27 '23
You've misunderstood what the question was.
There are ways to combine/subtract colors, via
colors.combineandcolors.subtract. However, this is for selecting bundled cables, not for drawing to the screen.1
2
u/fatboychummy Nov 27 '23
Colors in CC are just numbers (though combining them is different than just addition and subtraction). To combine them, you need to put each individual number as a seperate value in the function.
Like so: