BigHeadFox

MC Redstone Monitor

Aug 7th, 2025
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | Source Code | 0 0
  1. local l
  2. local b
  3. local r
  4. local lt = "TEMP: "
  5. local bt = "WASTE: "
  6. local rt = "FUEL: "
  7. local isOK = true
  8. local mon = peripheral.find("monitor")
  9.  
  10. mon.clear()
  11.  
  12. local function IsOK(rsStr)
  13.     if rsStr < 15 then
  14.         return true
  15.     else
  16.         return false
  17.     end
  18. end
  19.  
  20. local function TextColor(isOK)
  21.     if isOK then
  22.         return 8192
  23.     else
  24.         return 16384
  25.     end
  26. end
  27.  
  28. local function StatusText(isOK)
  29.     if isOK then
  30.         return "OK"
  31.     else
  32.         return "ERROR"
  33.     end
  34. end
  35.  
  36. local function SetText(x,y,isOk,t,s)
  37.     mon.setCursorPos(x,y)
  38.     mon.setTextColor(1)
  39.     mon.write(t)
  40.     mon.setTextColor(TextColor(isOK))
  41.     mon.write(StatusText(isOK))
  42. end
  43.  
  44. while true do
  45.     os.pullEvent("redstone")
  46.  
  47.     l = rs.getAnalogInput("left")
  48.     b = rs.getAnalogInput("back")
  49.     r = rs.getAnalogInput("right")
  50.     isOK = IsOK(l)
  51.     SetText(1,1,isOK,lt,l)
  52.     isOK = IsOK(b)
  53.     SetText(1,2,isOK,lt,b)
  54.     isOK = IsOK(r)
  55.     SetText(1,3,isOK,lt,r)
  56. end
Advertisement
Add Comment
Please, Sign In to add comment