View difference between Paste ID: sx71ayF2 and K7kWzLkn
SHOW: | | - or go back to the newest paste.
1
modem = peripheral.wrap("back")
2-
mon = peripheral.wrap("left")
2+
mon = peripheral.wrap('monitor_1')
3-
max = 2140000000000
3+
max = 9880000000
4
monX, monY = mon.getSize()
5
6
modem.open(1)
7
modem.open(2)
8
9
print("listening")
10
11
function clear()
12
  mon.setBackgroundColor(colors.black)
13
  mon.clear()
14
  mon.setCursorPos(1,1)
15
  end
16
  
17
function drawText(x, y, text, color_txt, color_bg)
18
mon.setTextColor(color_txt)
19
mon.setBackgroundColor(color_bg)
20
mon.setCursorPos(x,y)
21
mon.write(text)
22
end
23
24
function drawLine(x, y, length, size, color_bar)
25
for yPos = y, y+size-1 do
26
  mon.setBackgroundColor(color_bar)
27
  mon.setCursorPos(x, yPos)
28
  mon.write(string.rep(" ", length))
29
  end
30
end
31
32
function drawProg(x, y, name, length, size, minVal, maxVal, color_bar, color_bg)
33
  drawLine(x, y, length, size, color_bg)
34
  local barSize = math.floor((minVal/maxVal)*length)
35
  drawLine(x, y, barSize, size, color_bar)
36
  local text = name .." ".. math.floor((minVal/maxVal)*100) .."%"
37
  drawText(monX/2-#text/2, y+size/2, text, colors.black, colors.green)
38
end
39
40
while true do
41
 event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
42-
 local percent = math.floor((message/2140000000000)*100)
42+
 local percent = math.floor((message/max )*100)
43
 term.clear()
44
 term.setCursorPos(1,1)
45
 print("Receiving Energy Core Information")
46
 mon.getSize()
47
 mon.setCursorPos(1,1)
48
 mon.setTextColor(colors.red)
49
 mon.setTextScale(1)
50
 mon.write("Current Power: " ..message)
51
 mon.setCursorPos(1,2)
52-
 mon.write("Max Power: 2140000000000 RF")
52+
 mon.write("Max Power: 9880000000RF")
53
 mon.setCursorPos(1,3)
54
 mon.write("Percent Full: " .. percent .."%")
55
 drawProg(2, 5, "Completed", monX-2, 3, percent, 100, colors.green, colors.red)
56
sleep(.2)
57
clear()
58
  end