View difference between Paste ID: b0VH6y6c and vFRwHXu8
SHOW: | | - or go back to the newest paste.
1
m = peripheral.wrap("back")
2
3
rednet.open("top")
4
5
data = {}
6
7
function drawLine(m,x, y, lenght, color)
8
    bgColor = m.getBackgroundColor()
9
    for i = x, (lenght + x) do
10
        m.setCursorPos(i,y)
11
        m.setBackgroundColor(color)
12
        m.write(" ")
13
    end
14
    m.setBackgroundColor(bgColor)
15
end
16
17
function fetchData() 
18
    while true do
19
        e, id, d,c = os.pullEvent("rednet_message")
20
        if id == 0 then
21
            data = textutils.unserialize(d)
22
        end
23
    end
24
end
25
26
function displayData()
27
    os.sleep(5)
28
    while true do
29
        m.clear()
30
        m.setBackgroundColor(colors.black)
31
        m.setCursorPos(1, 1)
32
        if data["active"] then
33
            m.write("Reactor Active: Yes")
34
        else
35
            m.write("Reactor Active: No")
36
        end
37
        m.setCursorPos(1, 2)
38
        m.write("Network Energy: " .. data["energy"] .. "%")
39
        
40
        drawLine(m, 5, 10, colors.green)
41
        os.sleep(1)
42
    end
43
end
44
45-
end
45+
46
47