Advertisement
Plazter

DeepResonance Tank Control2

Feb 23rd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.88 KB | None | 0 0
  1. -- NOTE: --
  2. -- EDIT THE ADRESS TO MAKE SURE ITS CORRECT!--
  3.  
  4. component = require("component")
  5. sides = require("sides")
  6. rs = component.proxy(component.get("279c"))
  7. colors = require("colors")
  8. transposer1 = component.proxy(component.get("ccee")) -- Fluid
  9. tank  = component.proxy(component.get("a8d7")) -- stats
  10. gpu = component.gpu
  11. term = require("term")
  12. keyboard = require("keyboard")
  13.  
  14. Scolors = { black = 0x000000,
  15. white = 0xf8f8ff,
  16. blue = 0x0000ff,
  17. lightGray = 0xd9d9d9,
  18. red = 0xff0000,
  19. purple = 0x9b30ff,
  20. carrot = 0xffa500,
  21. magenta = 0xcd00cd,
  22. lightBlue = 0x87cefa,
  23. yellow = 0xffff00,
  24. lime = 0x32cd32,
  25. pink = 0xffc0cb,
  26. gray = 0x696969,
  27. brown = 0x8b4500,
  28. green = 0x006400,
  29. cyan = 0x008b8b,
  30. olive = 0x6b8e23,
  31. gold = 0x8b6914,
  32. orangered = 0xdb4e02,
  33. diamond = 0x0fa7c7,
  34. crimson = 0xaf002a,
  35. fuchsia = 0xfd3f92,
  36. folly = 0xff004f,
  37. frenchBlue = 0x0072bb,
  38. lilac = 0x86608e,
  39. flax = 0xeedc82,
  40. darkGray = 0x563c5c,
  41. englishGreen = 0x1b4d3e,
  42. eggplant = 0x614051,
  43. deepPink  = 0xff1493,
  44. ruby = 0x843f5b,
  45. orange = 0xf5c71a,
  46. lemon = 0xffd300,
  47. darkBlue = 0x002e63,
  48. bitterLime = 0xbfff00 }
  49.  
  50. function fluid()
  51.   if transposer1.getTankLevel(sides.west) ~= (transposer1.getTankCapacity(sides.west) / 100 * 50) then
  52.     transposer1.transferFluid(sides.east, sides.west, 200)
  53.   else
  54.     os.sleep(2)
  55.  end
  56. end
  57.  
  58. function laser()
  59.   if tank.getPurity(sides.east) >= 0.70 and tank.getFluidAmount(sides.east) >= 6000 then
  60.     if tank.getStrength(sides.east) < 0.40 and tank.getEfficiency(sides.east) < 0.40 then  
  61.       rs.setBundledOutput(sides.top, colors.red, 15)
  62.       else
  63.       rs.setBundledOutput(sides.top, colors.red, 0)
  64.     end
  65.   else
  66.     rs.setBundledOutput(sides.top, colors.red, 0)
  67.     return
  68.   end
  69. end
  70.  
  71. function draw_text(x, y, text, text_color, bg_color)
  72.   if text_color == nil then text_color = Scolors.white end
  73.   if bg_color == nil then bg_color = Scolors.black end
  74.     gpu.setBackground(bg_color)
  75.     gpu.setForeground(text_color)
  76.     gpu.set(x,y,text)
  77.     gpu.setBackground(Scolors.black)
  78.     gpu.setForeground(Scolors.white)
  79. end
  80.  
  81. function screen()
  82.    temp = tank.getPurity(sides.east)
  83.    purity = tonumber(string.format("%.f", 100*temp))
  84.    draw_text(1,1,"Stats.......: ",Scolors.gold)
  85.    draw_text(1,2,"Fluid Amount: ".. tank.getFluidAmount(sides.east).."mB",Scolors.crimson)
  86.    draw_text(1,3,"Purity......: ".. purity .."%",Scolors.bitterLime)
  87.    draw_text(1,4,"Effciency...: ".. tonumber(string.format("%.1f", (100*tank.getEfficiency(sides.east)))).."%",Scolors.frenchBlue)
  88.    draw_text(1,5,"Strength....: ".. tonumber(string.format("%.1f", (100*tank.getStrength(sides.east)))).."%",Scolors.eggplant)
  89.   return
  90. end
  91.  
  92.  
  93. gpu.setResolution(23,6)
  94. term.clear()
  95. while true do
  96.   if keyboard.isKeyDown(keyboard.keys.w) and keyboard.isControlDown() then
  97.      term.clear()
  98.      gpu.setResolution(150,50)
  99.      os.exit()
  100.   end
  101.   fluid()
  102.   laser()
  103.   screen()
  104.   os.sleep(1)
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement