Advertisement
Guest User

startup.lua

a guest
Apr 7th, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. mon = peripheral.wrap("top")
  2.  
  3. rednet.open("bottom")
  4.  
  5. mon.setTextScale(0.5)
  6.  
  7. function getData()
  8.     local ids = {73,70,69,71,72,75}
  9.     local states = {}
  10.     for r = 1,6 do
  11.         print("Waiting for response from Cp"..r)
  12.         while true do
  13.             local senderID, mess, dist = rednet.receive()
  14.             if senderID == ids[r] then
  15.                 states[r] = mess
  16.                 break
  17.             end    
  18.         end
  19.     end
  20.     return states
  21. end
  22.  
  23.  
  24. function show()
  25.     data = getData()
  26.     mon.clear()
  27.     mon.setTextColor(colors.white)
  28.     mon.setCursorPos(1,1)
  29.     mon.write("Breeding apiary:")
  30.     for k = 3, 8 do
  31.         mon.setCursorPos(6,k)
  32.         mon.write("Apiary n°"..(k-2)..":")
  33.     end
  34.     mon.setCursorPos(20,1)
  35.     mon.write("State:")
  36.     for v = 3, 8 do
  37.         if data[(v-2)] == "In progress.." then
  38.             mon.setTextColor(colors.green)
  39.         else
  40.             mon.setTextColor(colors.red)
  41.         end
  42.         mon.setCursorPos(20,v)
  43.         mon.write(data[(v-2)])
  44.         mon.setTextColor(colors.white)
  45.     end
  46. end
  47.  
  48. while true do
  49.     show()
  50.     sleep(2)
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement