Advertisement
Plazter

For Daniel

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