View difference between Paste ID: CvhHhxN4 and HhLqXgzD
SHOW: | | - or go back to the newest paste.
1
--[[ masterdisasterHD 2013 (c) All rights reserved. ]]--
2
3
os.pullEvent = os.pullEventRaw
4
5
running = true
6
7
if not fs.exists(".cSide") then
8
 write("Cable side: ")
9
 B = read()
10
 A = fs.open(".cSide", "w")
11
 A.write(B)
12
 A.close()
13
 cSide = B
14
else
15
 A = fs.open(".cSide", "r")
16
 B = A.readAll()
17
 A.close()
18
 for i,v in pairs(rs.getSides()) do
19
  if B~=v then
20
  
21
  else
22
   cSide = B
23
   break
24
  end
25
  cSide = "back"
26
 end
27
end
28
29
states = {}
30
for i=1, 17 do
31
  states[i] = "Offline"
32
end
33
34
function draw()
35
 term.clear()
36
 D = 1
37
  for i=1, 17 do
38
   if i < 17 then    
39
    paintutils.drawLine(1, i+1, 51, i+1, D)
40
    D = 2^i
41
   end 
42
    
43
    if states[i] == "Online" then term.setTextColor(colors.lime) else term.setTextColor(colors.red) end
44
    term.setCursorPos(2, i+1)
45
      if i~=17 then
46
       if i==15 and states[15]=="Offline" then
47
        term.setTextColour(colors.white)
48
       elseif i==6 and states[6]=="Online" then
49
        term.setTextColour(colors.blue)
50
       end
51
        print("Cable "..tostring(i)..": "..states[i])
52
      elseif i==17 then
53
        print("All Cable's: "..states[i])
54
    end
55
  end
56
end
57
58
while running do
59
local sCount = 0 
60
 for i=1,16 do
61
  if states[i]=="Online" then sCount = sCount + 1
62
  else
63
  end
64
 end
65
 if sCount ~=16 then states[17]="Offline"
66
 elseif sCount==16 then states[17]="Online"
67
 end
68
  draw()
69
  _, key, y, x = os.pullEvent("mouse_click")
70
  -- Yes, I know x and y are reverse
71
  if _ or key then
72
  if x ~= nil then
73
   x = x - 1
74
  end
75
  end
76
 if x ~= nil then
77
  if x >=1 and x <= 16 then
78
    if states[x] == "Online" then states[x] = "Offline"
79
    elseif states[x] == "Offline" then states[x] = "Online" end
80
  elseif x == 17 then
81
    if states[x] == "Online" then B = "Offline" states[x] = "Offline"
82
    elseif states[x] == "Offline" then B = "Online" states[x] = "Online" end  
83
    for i=1,17 do
84
     states[i] = B
85
    
86
    end
87
    draw()
88
  end
89
 end
90
  
91
  local color = 0
92
  for i, v in pairs(states) do
93
    if v == "Online" then
94
      color = color + (2^(i-1))
95
    end
96
  end
97
  rs.setBundledOutput(cSide, color)
98
end