Advertisement
gunny576

Coil Display System

May 1st, 2020
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. --[[
  2. Author: Gunny576
  3. Date: 4/26
  4. Coil Monitor System-Display
  5.  
  6.  
  7. Usage: This program will listen to the wireless network to display coil information to a monitor.
  8. --]]
  9. --configs
  10. coils = 8
  11. offeset=0
  12.  
  13.  
  14. --peripheral establisment for monitor and Modem.
  15. mon = peripheral.wrap("right")
  16. local modem = peripheral.wrap("left")
  17. --establishes our display array
  18. payload={}
  19. for i=1,coils do
  20.     modem.open(i+offest)
  21.     payload[i][1]=i
  22.     payload[i][2]=0
  23. end
  24.  
  25.  
  26. modem.open(1)
  27. mon.clear()
  28. mon.setTextScale(2)
  29. a = 0
  30. b = 0
  31.  
  32.  
  33. while true do
  34.     local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  35.     print(message[0].."% Cell "..message[1] )
  36.     payload[senderChannel][2]=message[0]
  37.     mon.clear()
  38.     mon.setBackgroundColor(colors.black)
  39.  
  40.     for i=1,coils do
  41.         mon.setCursorPos(1,i)
  42.         mon.write("Coil "..payload[i][1].. " is at "..payload[i][2].."%")
  43.         end
  44.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement