Advertisement
TheModerGuy

boiler and turbine monitor

Aug 30th, 2013
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. boiler = peripheral.wrap("solid_fueled_boiler_firebox_0")
  2. turbine = peripheral.wrap("steam_turbine_housing_1")
  3. mon = peripheral.wrap("left")
  4.  
  5. function roundNum(val, decimal)
  6.   if decimal then
  7.       return math.floor(((val * 10^decimal) + 0.5) / (10^decimal))
  8.   end  
  9. end    
  10.  
  11. while true do
  12.  
  13. local connected = turbine.isAddedToEnergyNet()
  14. local help = turbine.needsMaintenance()
  15.  
  16. local temp = roundNum(boiler.getTemperature(), 0)
  17.  
  18. mon.setTextScale(2)
  19. local x,y = mon.getSize()
  20. mon.clear()
  21. if temp < 100 or boiler.needsFuel() == true then
  22.   mon.setTextColor(colors.red)
  23.  
  24. elseif temp < 400 then
  25.   mon.setTextColor(colors.orange)
  26.  
  27. elseif temp > 400 then
  28.   mon.setTextColor(colors.lime)
  29. end
  30.  
  31. local fuel = boiler.needsFuel()
  32. mon.setCursorPos(1,1)
  33. if fuel == true then
  34.   mon.write("FUEL LOW")
  35. end
  36.  
  37.  
  38. mon.setCursorPos(x/2-1,2)
  39. mon.write("HEAT%")
  40. mon.setCursorPos(x/2-1,3)
  41. mon.write(temp / 5 .. " %")
  42.  
  43.  
  44. if help=="true" then
  45.     mon.setTextColor(colors.red)
  46.     mon.setCursorPos(x/2-1,y-2)
  47.     mon.write("POWER")
  48.     mon.setCursorPos(x/2-2,y-1)
  49.     mon.write("OFFLINE")
  50. end
  51. if help=="false" then
  52.     mon.setTextColor(colors.lime)
  53.     mon.setCursorPos(x/2-1,y-2)
  54.     mon.write("POWER")
  55.     mon.setCursorPos(x/2-1,y-1)
  56.     mon.write("ONLINE")
  57. end
  58.  
  59. sleep(0.2)
  60. sleep(0)
  61.  
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement