Daniel_I_Am

BR turbine management

Aug 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.36 KB | None | 0 0
  1. -- turbine.setInductorEngaged
  2. component   = require("component")
  3. turbine     = component.br_turbine
  4. redstone    = component.redstone
  5. event       = require("event")
  6. gpu         = component.gpu
  7. term        = require("term")
  8. sides       = require("sides")
  9. os          = require("os")
  10.  
  11. -----------------
  12. --[[Colors Table]]--
  13. colors = { black = 0x000000, white = 0xf8f8ff, blue = 0x0000ff, lightGray = 0xd9d9d9, red = 0xff0000,
  14. purple = 0x9b30ff, carrot = 0xffa500, magenta = 0xcd00cd, lightBlue = 0x87cefa, yellow = 0xffff00,
  15. lime = 0x32cd32, pink = 0xffc0cb, gray = 0x696969, brown = 0x8b4500, green = 0x006400, cyan = 0x008b8b,
  16. olive = 0x6b8e23, gold = 0x8b6914, orangered = 0xdb4e02, diamond = 0x0fa7c7,crimson = 0xaf002a,fuchsia = 0xfd3f92,
  17. folly = 0xff004f, frenchBlue = 0x0072bb, lilac = 0x86608e, flax = 0xeedc82, darkGray = 0x563c5c,
  18. englishGreen = 0x1b4d3e, eggplant = 0x614051, deepPink  = 0xff1493, ruby = 0x843f5b, orange = 0xf5c71a,
  19. lemon = 0xffd300, darkBlue = 0x002e63, bitterLime = 0xbfff00 }
  20. -------------------
  21.  
  22. --[[Variables]]--
  23. Turbine_On  = 24500
  24. Turbine_Off = 24200
  25. w           = 50
  26. h           = 3
  27. Default_bg  = colors.gray
  28. Border_bg   = colors.white
  29. text_col    = colors.white
  30. status_col  = colors.black
  31.  
  32. function guiBorders(x,y,len,height,str) -- BORDER FUNC FOR GUI
  33.   gpu.setBackground(Border_bg)
  34.   gpu.fill(x,y,len,height,str)
  35.   gpu.setBackground(Default_bg)
  36. end
  37.  
  38. function GUI() -- SETS THE GUI LAYOUT (GRAPHICAL USER INTERFACE)
  39.   gpu.setResolution(w,h)
  40.   gpu.set(1,2,"Speed of turbine is currently:")
  41. end
  42.  
  43. function Center(y,text) -- CENTERS TEXT  
  44.   w, h = gpu.getResolution()
  45.   term.setCursor((w-string.len(text))/2+1, y)
  46.   term.write(text)
  47. end
  48.  
  49. function info(title,x,y) -- Rewriting of gpu.set
  50.   gpu.set(x,y,title)
  51. end
  52.  
  53. function Display()
  54.   Center(2,"Turbine")
  55.   info("Status: ", 2, 3)
  56. end
  57.  
  58. function Update()
  59.   if turbine.getRotorSpeed() >= Turbine_On then
  60.     -- Set active
  61.     turbine.setInductorEngaged(true)
  62.     gpu.set(1,1,"Turbine is currently on")
  63.   elseif turbine.getRotorSpeed() <= Turbine_Off then
  64.     -- Set offline
  65.     turbine.setInductorEngaged(false)
  66.     gpu.set(1,1,"Turbine is currently off")
  67.   end
  68.   gpu.set(1,3,tostring(math.floor(turbine.getRotorSpeed())).." RPM")
  69. end
  70.  
  71. term.clear()
  72. GUI()
  73. Display()
  74. while true do
  75.   if redstone.getInput(sides.south) then
  76.     Update()
  77.   end
  78.   os.sleep(0.1)
  79. end
Advertisement
Add Comment
Please, Sign In to add comment