Advertisement
Guest User

GrayTurbine.lua

a guest
Mar 4th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 KB | None | 0 0
  1. component = require 'component'
  2. local event = require("event")
  3. local fs = require("filesystem")
  4. local keyboard = require("keyboard")
  5. local shell = require("shell")
  6. local term = require("term")
  7. local text = require("text")
  8. local unicode = require("unicode")
  9. local sides = require("sides")
  10. local colors=require("colors")
  11.  
  12. local gpu=component.gpu
  13. side = require 'sides'
  14. rs = component.getPrimary('redstone')
  15.  
  16. RS_CONTROL = side.south
  17. RF_BUFFER_MAX = 9000000
  18. RF_BUFFER_MIN = 1000
  19. TEMP_MAX = 300
  20. TEMP_MIN = 100
  21. local tickCnt = 0
  22. local turbineCnt = 1
  23. local hours = 0
  24. local mins = 0
  25.  
  26. REACTORS = {}
  27. TURBINES = {}
  28. local running = true
  29.  
  30. gpu.setResolution(80,25)
  31.  
  32. for address, type in component.list() do
  33.     if type == 'br_reactor' then
  34.         table.insert(REACTORS, component.proxy(address))
  35.         print('Found reactor at ' .. address)
  36.     elseif type == 'br_turbine' then
  37.         table.insert(TURBINES, component.proxy(address))
  38.         print('Found turbine at ' .. address)
  39.     end
  40. end
  41.  
  42. local function onKeyDown(opt)
  43.   if opt == keyboard.keys.q then
  44.     gpu.setResolution(160, 50)
  45.     running = false
  46.   end
  47. end
  48.  
  49. while running do -- Main Loop
  50. term.clear()
  51.   tickCnt = tickCnt + 1
  52.   if tickCnt == 20 then
  53.     mins = mins + 1
  54.     tickCnt = 0
  55.   end
  56.  
  57.   if mins == 60 then
  58.     hours = hours + 1
  59.     mins = 0
  60.   end
  61.  
  62. turbineCnt = 1
  63. turbineActive = 'ACTIVE'
  64.   for _, t in pairs(TURBINES) do
  65.     if t.getActive == false then
  66.       turbineActive = 'SHUT DOWN'
  67.     end
  68.        print('\n-----' .. 'Turbine ' .. turbineCnt .. ' ' .. turbineActive ..'-----')
  69.        print('Turbine ' .. turbineCnt ..' power at ' .. t.getEnergyProducedLastTick() .. ' RF/t')
  70.        print('Turbine ' .. turbineCnt ..' RF stored: ' ..  t.getEnergyStored())      
  71.        print('Turbine ' .. turbineCnt ..' Rotor Speed ' .. t.getRotorSpeed())
  72.        turbineCnt = turbineCnt + 1
  73.     end
  74.  
  75. print('\n---------------------------------------------------------\n')
  76. print('Current uptime: ' .. hours .. ' hours ' .. mins .. ' mins')
  77. print('Data updates every second. Tick Count: ' .. tickCnt)
  78.  
  79.   local event, address, arg1, arg2, arg3 = event.pull(1)
  80.   if type(address) == "string" and component.isPrimary(address) then
  81.     if event == "key_down" then
  82.       onKeyDown(arg2)
  83.     end
  84.   end
  85.     os.sleep(0.04) -- Don't lag out the server
  86.  
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement