I suppose you could if you really wanted to
local tRooms = {
{
color = "white",
state = false
},
{
color = "orange",
state = false
},
{
color = "magenta",
state = false
}
}
while true do
os.pullEvent"redstone"
local bundleColor = rs.getBundledInput"side"
for _i,room in ipairs(tRooms) do
if colors.test(bundleColor,colors[room.color]) then
room.state = not room.state
break
end
end
end
Your error is the result of you using pairs the wrong way
for mechanism,mSignal in pairs(mechanismSignal) do
for _,mState in pairs(states) do
cycle(mechanismSignal[mechanism], mechanismSignal[mSignal], states[mState])
Lemme break down the syntax of a pairs loop for you
for tableKey,tableValue in pairs(table) do
--the local tableKey here contains the table key holding the table value, which is stored in tableValue
So, what you're effectively doing here
for mechanism,mSignal in pairs(mechanismSignal) do
for _,mState in pairs(states) do
cycle(mechanismSignal[mechanism], mechanismSignal[mSignal], states[mState]) --the first argument here is correct, though redundant. The second one is whatever's stored under the key of what mechanismSignal has as it's value under the key mechanism. Same goes for the thrid
It should instead be
for mechanism,mSignal in pairs(mechanismSignal) do
for _,mState in pairs(states) do
cycle(mSignal, mSignal, mState)
Also, you don't appear to even be using the first argument (mechanism) in the cycle function.