Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ masterdisasterHD 2013 (c) All rights reserved. ]]--
- os.pullEvent = os.pullEventRaw
- running = true
- if not fs.exists(".cSide") then
- write("Cable side: ")
- B = read()
- A = fs.open(".cSide", "w")
- A.write(B)
- A.close()
- cSide = B
- else
- A = fs.open(".cSide", "r")
- B = A.readAll()
- A.close()
- for i,v in pairs(rs.getSides()) do
- if B~=v then
- else
- cSide = B
- break
- end
- cSide = "back"
- end
- end
- states = {}
- for i=1, 17 do
- states[i] = "Offline"
- end
- function draw()
- term.clear()
- D = 1
- for i=1, 17 do
- if i < 17 then
- paintutils.drawLine(1, i+1, 51, i+1, D)
- D = 2^i
- end
- if states[i] == "Online" then term.setTextColor(colors.lime) else term.setTextColor(colors.red) end
- term.setCursorPos(2, i+1)
- if i~=17 then
- if i==15 and states[15]=="Offline" then
- term.setTextColour(colors.white)
- elseif i==6 and states[6]=="Online" then
- term.setTextColour(colors.blue)
- end
- print("Cable "..tostring(i)..": "..states[i])
- elseif i==17 then
- print("All Cable's: "..states[i])
- end
- end
- end
- while running do
- local sCount = 0
- for i=1,16 do
- if states[i]=="Online" then sCount = sCount + 1
- else
- end
- end
- if sCount ~=16 then states[17]="Offline"
- elseif sCount==16 then states[17]="Online"
- end
- draw()
- _, key, y, x = os.pullEvent("mouse_click")
- -- Yes, I know x and y are reverse
- if _ or key then
- if x ~= nil then
- x = x - 1
- end
- end
- if x ~= nil then
- if x >=1 and x <= 16 then
- if states[x] == "Online" then states[x] = "Offline"
- elseif states[x] == "Offline" then states[x] = "Online" end
- elseif x == 17 then
- if states[x] == "Online" then B = "Offline" states[x] = "Offline"
- elseif states[x] == "Offline" then B = "Online" states[x] = "Online" end
- for i=1,17 do
- states[i] = B
- end
- draw()
- end
- end
- local color = 0
- for i, v in pairs(states) do
- if v == "Online" then
- color = color + (2^(i-1))
- end
- end
- rs.setBundledOutput(cSide, color)
- end
Add Comment
Please, Sign In to add comment