Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----Manage-Colors-----
- 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,["need"] = "pur",["neednum"] = false}
- Table[2] = {["on"] = false,["name"] = "Green Lamp",["color"] = colors.red,["need"] = "gre",["neednum"] = false}
- Table[101] = {["on"] = false,["name"] = "Sprinkler 1",["color"] = colors.lime,["need"] = "spri",["neednum"] = 1}
- Table[102] = {["on"] = false,["name"] = "Sprinkler 2",["color"] = colors.yellow,["need"] = "spri",["neednum"] = 2}
- Table[103] = {["on"] = false,["name"] = "Sprinkler 3",["color"] = colors.brown,["need"] = "spri",["neednum"] = 3}
- Table[104] = {["on"] = false,["name"] = "Sprinkler 4",["color"] = colors.white,["need"] = "spri",["neednum"] = 4}
- all = colors.combine(colors.red,colors.yellow,colors.lime,colors.brown,colors.purple,colors.white)
- rs.setBundledOutput("top",all)
- --------functions--------------
- 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)
- for i , v in pairs(Table) do
- c = tonumber(string.match(t,"%d+"))
- if Table[i]["neednum"] ~= false then
- print("read "..c)
- print("Tab "..Table[i]["neednum"])
- if string.find(t,Table[i]["need"]) == true and Table[i]["neednum"] == c then
- print("with num"..i)
- return i
- end
- else
- if string.find(t,Table[i]["need"]) then
- print("no num"..i)
- return i
- end
- end
- end
- --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") and string.find(t,"spri") 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()
- num = test(io.read())
- top = rs.getBundledOutput("top")
- print(c)
- print(Table[102]["neednum"])
- os.sleep(4)
- if num then
- read = tonumber(num)
- 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
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement