Jackson_Pike

Turbine Control

Jun 24th, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.28 KB | None | 0 0
  1. ---------------Jackson_Pike's Turbine Program---
  2. local function peripherals()
  3. mon = peripheral.wrap("right")
  4. turb = peripheral.wrap("BigReactors-Turbine_0")
  5. monX, monY = mon.getSize()
  6. name = turb
  7. end
  8. ------------------------------------------------
  9. local function drawMenus(color)
  10.   mon.setCursorPos(1, 1)
  11.   mon.setBackgroundColor(color)
  12.   mon.write(string.rep(" ", monX))
  13.   mon.setCursorPos(1, monY)
  14.   mon.setBackgroundColor(color)
  15.   mon.write(string.rep(" ", monX))
  16. end
  17. local function writeText(xPos, yPos, bgcolor, txcolor, text)
  18.   mon.setCursorPos(xPos, yPos)
  19.   mon.setBackgroundColor(bgcolor)
  20.   mon.setTextColor(txcolor)
  21.   mon.write(text)
  22. end
  23. local function clear()
  24.   mon.setBackgroundColor(colors.black)
  25.   mon.clear()
  26. end
  27. local function getData()
  28.   RFStored = math.floor(turb.getEnergyStored())
  29.   RF = math.floor(turb.getEnergyProducedLastTick())
  30.   Rotor = math.floor(turb.getRotorSpeed())
  31.   poll = turb.getActive()
  32.   Steam = turb.getInputAmount()
  33.   sleep(0.1)
  34. end
  35. local function displayData()
  36.   writeText(1, 3, colors.black, colors.yellow, "RF/Tick: ")
  37.   writeText(10, 3, colors.black, colors.white, RF.." RF/T")
  38.   writeText(1, 4, colors.black, colors.yellow, "Rotor Speed: ")
  39.   writeText(14, 4, colors.black, colors.white, Rotor.." RPM")
  40.   writeText(1, 5, colors.black, colors.yellow, "Energy Stored: ")
  41.   writeText(16, 5, colors.black, colors.white, RFStored.." RF")
  42.   writeText(1, 6, colors.black, colors.yellow, "Steam Stored: ")
  43.   writeText(15, 6, colors.black, colors.white, Steam.."mB/2000mB")
  44. end
  45. local function homepage()
  46.   if poll == true then
  47.   clear()
  48.   drawMenus(colors.blue)
  49.   writeText(monX/2-4.5, 1, colors.blue, colors.white, "Turbine 1")
  50.   writeText(1, 2, colors.black, colors.yellow, "Status: ")
  51.   writeText(8, 2, colors.black, colors.green, "ONLINE")
  52.   writeText(monX-3, 1, colors.blue, colors.white, "OFF")
  53.   displayData()
  54.   else
  55.   clear()
  56.   drawMenus(colors.gray)
  57.   writeText(monX/2-4.5, 1, colors.gray, colors.white, "Turbine 1")
  58.   writeText(1, 2, colors.black, colors.yellow, "Status: ")
  59.   writeText(8, 2, colors.black, colors.red, "OFFLINE")
  60.   writeText(monX-3, 1, colors.gray, colors.white, "ON")
  61.   displayData()
  62.   end
  63. end
  64. while true do
  65. peripherals()
  66. mon.setTextScale(1)
  67. getData()
  68. homepage()
  69. sleep(1)
  70. mon.clear()
  71. homepage()
  72. end
Advertisement
Add Comment
Please, Sign In to add comment