Advertisement
Guest User

startup.lua

a guest
Jul 23rd, 2021
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. m = peripheral.wrap("back")
  2.  
  3. rednet.open("top")
  4.  
  5. data = {}
  6.  
  7. function fetchData()
  8.     while true do
  9.         e, id, d,c = os.pullEvent("rednet_message")
  10.         if id == 0 then
  11.             data = textutils.unserialize(d)
  12.         end
  13.     end
  14. end
  15.  
  16. function displayData()
  17.     os.sleep(5)
  18.     while true do
  19.         m.clear()
  20.         m.setBackgroundColor(colors.black)
  21.         m.setCursorPos(1, 1)
  22.         if data["active"] then
  23.             m.write("Reactor Active: Yes")
  24.         else
  25.             m.write("Reactor Active: No")
  26.         end
  27.         m.setCursorPos(1, 2)
  28.         m.write("Network Energy: " .. data["energy"] .. "%")
  29.        
  30.         drawLine(m, 5, 10, colors.green)
  31.         os.sleep(1)
  32.     end
  33. end
  34.  
  35. parallel.waitForAll(fetchData, displayData)
  36.  
  37. function drawLine(m,x, y, lenght, color)
  38.     bgColor = m.getBackgroundColor()
  39.     for i = x, (lenght + x) do
  40.         m.setCursorPos(i,y)
  41.         m.setBackgroundColor(color)
  42.         m.write(" ")
  43.     end
  44.     m.setBackgroundColor(bgColor)
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement