Daniel_I_Am

Draconic Evolution Power Ball OC Script

Aug 13th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.20 KB | None | 0 0
  1. component = require("component")
  2. sides = require("sides")
  3. term = require("term")
  4. gpu = component.gpu
  5.  
  6. if component.draconic_rf_storage ~= nil then
  7.   draco = component.draconic_rf_storage
  8.   print("Core Found, Wrapped!")
  9.   os.sleep(1)
  10.   else
  11.   print("Core not found..")
  12.   os.sleep(1)
  13. end
  14.  
  15. colors = { black = 0x000000, white = 0xf8f8ff, blue = 0x0000ff, lightGray = 0xd9d9d9, red = 0xff0000,
  16.             purple = 0x9b30ff, carrot = 0xffa500, magenta = 0xcd00cd, lightBlue = 0x87cefa, yellow = 0xffff00,
  17.             lime = 0x32cd32, pink = 0xffc0cb, gray = 0x696969, brown = 0x8b4500, green = 0x006400, cyan = 0x008b8b,
  18.             olive = 0x6b8e23, gold = 0x8b6914, orangered = 0xdb4e02, diamond = 0x0fa7c7,crimson = 0xaf002a,fuchsia = 0xfd3f92,
  19.             folly = 0xff004f, frenchBlue = 0x0072bb, lilac = 0x86608e, flax = 0xeedc82, darkGray = 0x563c5c,
  20.             englishGreen = 0x1b4d3e, eggplant = 0x614051, deepPink  = 0xff1493, ruby = 0x843f5b, orange = 0xf5c71a,
  21.             lemon = 0xffd300, darkBlue = 0x002e63, bitterLime = 0xbfff00
  22.             }
  23. -------------------------
  24.  
  25. --Vars --
  26.   Border_bg = colors.white
  27.   Default_bg = colors.gray
  28.   text_col = colors.white
  29. ---------
  30.  
  31. -- Resolution --
  32. gpu.setResolution(54,7)
  33.  
  34. -------------------------
  35. -- Functions --
  36. function guiBorders(x,y,len,height,str)
  37.   gpu.setBackground(Border_bg)
  38.   gpu.fill(x,y,len,height,str)
  39.   gpu.setBackground(Default_bg)
  40. end
  41.  
  42. function GUI()
  43.   gpu.setBackground(Default_bg)
  44.   term.clear()
  45.   w,  h = gpu.getResolution()
  46.   guiBorders(1,1,w,1," ")
  47.     for i = 1,h do
  48.      -- guiBorders(1,i,1,1," ")
  49.      -- guiBorders(w,i,1,1," ")
  50.     end
  51.   guiBorders(1,h,w,1," ")
  52.   gpu.setForeground(text_col)
  53. end
  54.  
  55. function Center(y,text)
  56.     w, h = gpu.getResolution()
  57.     term.setCursor((w-string.len(text))/2+1, y)
  58.     term.write(text)
  59. end
  60.  
  61. function comma_value(n) -- credit http://richard.warburton.it
  62.   local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
  63.   return left..(num:reverse():gsub('(%d%d%d)','%1.'):reverse())..right
  64. end
  65.  
  66. function Disp()
  67.   Center(2,"POWER STORAGE")
  68.   cut = string.len(tostring(current))
  69.   gpu.set(2,3,"Stored....: ")
  70.   if cap =="∞" then
  71.     Center(4,"   "..comma_value(string.format("%.i",current)) .."/∞RF")
  72.   else
  73.     Center(4,"   "..comma_value(string.format("%.i",current)) .." /"..comma_value(string.format("%.i",cap)).." RF  ("..string.format("%.i",currentP).."%)    ")
  74.   end
  75.   gpu.set(2,5, "Usage.....: ")
  76.     OldCurrent = current
  77.     os.sleep(1)
  78.     Center(6,"                             ")
  79.     Current = draco.getEnergyStored()
  80.       if Current >= OldCurrent then
  81.         gpu.setForeground(colors.lime)
  82.         Center(6,"+"..comma_value(string.format("%.f", ((Current-OldCurrent)/20))).. " RF/t ")
  83.         gpu.setForeground(text_col)
  84.       else --if Current < OldCurrent then
  85.         gpu.setForeground(colors.red)
  86.         Center(6,comma_value(string.format("%.f",((Current-OldCurrent)/20))) .. " RF/t ")
  87.         gpu.setForeground(text_col)
  88.       end
  89. end
  90.  
  91. GUI()
  92.  
  93. while true do
  94.   current = draco.getEnergyStored()
  95.  
  96.   cap = draco.getMaxEnergyStored()
  97.   if cap>3000000000000 then
  98.     cap = "∞"
  99.   else
  100.     currentP = math.floor(current/cap*100)
  101.   end
  102.   Disp()
  103. end
Advertisement
Add Comment
Please, Sign In to add comment