https://pastebin.com/yAGi3TXx
What did i made wrong?
The code is not polished and is a little mixed up.
-----Functions----- local function AddOutput(sSide,...) local c = colors.combine(rs.getBundledOutput(sSide),...) rs.setBundledOutput(sSide,c) end local function RemoveOutput(sSide,...) local c = colors.subtract(rs.getBundledOutput(sSide),...) rs.setBundledOutput(sSide,c) end -------Table--------- Table = {} Table[1]= {["on"] = false,["name"] = "Purple Lamp",["color"] = colors.purple} Table[2] = {["on"] = false,["name"] = "Green Lamp",["color"] = colors.red} Table[101] = {["on"] = false,["name"] = "Sprinkler 1",["color"] = colors.lime} Table[102] = {["on"] = false,["name"] = "Sprinkler 2",["color"] = colors.yellow} Table[103] = {["on"] = false,["name"] = "Sprinkler 3",["color"] = colors.brown} Table[104] = {["on"] = false,["name"] = "Sprinkler 4",["color"] = colors.white} all = colors.combine(colors.red,colors.yellow,colors.lime,colors.brown,colors.purple,colors.white) rs.setBundledOutput("top",all) ---------------------- local function showtable() term.setCursorPos(1,1) term.clear() for i , v in pairs(Table) do c = Table[i]["on"] local s = "off" if c == true then s = "on" else s = "off" end l = Table[i]["name"] io.write(l) Cursorx,CursorY = term.getCursorPos() term.setCursorPos(14,CursorY) io.write(s.."\n") end term.setCursorBlink(true) io.write("> ") end --------------------------- function test(thing) local t = string.lower(thing) if string.find(t,"pu") then return 1 elseif string.find(t,"gr") then return 2 elseif string.find(t,"1") then return 101 elseif string.find(t,"2") then return 102 elseif string.find(t,"3") then return 103 elseif string.find(t,"4") then return 104 else return false end end --------------------------- while true do showtable() read = test(io.read()) if read then tcolor = Table[read]["color"] if colors.test("top",tcolor) == true then Table[read]["on"] = true RemoveOutput("top",tcolor) elseif colors.test("top",tcolor) == false then Table[read]["on"] = false AddOutput("top",tcolor) end end read = false end