Advertisement
Guest User

startup

a guest
Oct 26th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 KB | None | 0 0
  1. mon = peripheral.wrap("monitor_0")
  2. core = peripheral.wrap("draconicevolution_tileenergypylon_0")
  3. tank = peripheral.wrap("tile_endertech_endertankvalve_0")
  4. bridge = peripheral.wrap("openperipheral_bridge_0")
  5.  
  6. debug = false
  7.  
  8. function fill(x1, x2, y1, y2, color)
  9.   if debug then print("Adding box from ("..x1..","..y1..") to ("..x2-x1..","..y2-y1..") with color: "..color) end
  10.   bridge.addBox(x1,y1,x2-x1,y2-y1, color)
  11. end
  12.  
  13. function init()
  14.   bridge.clear()
  15.   bridge.sync()
  16. end
  17.  
  18. function writeat(line, text, index)
  19.   if not index then index = 1 end
  20.   bridge.addText(index, line, text)
  21. end
  22.  
  23. function energy()
  24.   stored = core.getEnergyStored()
  25.   max = core.getMaxEnergyStored()
  26.   percfull = math.floor(stored/max*100)
  27.   percempty = 100 - math.ceil(stored/max*100)
  28.   x1,x2,y1,y2 = 100,500, 1, 40
  29.   x2 = x2 - x1
  30.   y2 = y2 - y1
  31.   eend = x2 * math.ceil(percfull / 100)
  32.   if debug then
  33.     print("Percentage full: "..percfull.."%")
  34.     print("Red: from "..x1.." to "..eend)
  35.     print("Black: from "..eend.." to "..x2)
  36.   end
  37.   fill(eend, x2, y1,y2, 0x000000)
  38.   fill(x1, eend, y1,y2, 0xFF0000)
  39.   writeat(x1, percfull.."%")
  40. end
  41.  
  42. function essence()
  43.   info = tank.getTankInfo("east")
  44.   stored = info[1]["contents"]["amount"]
  45.   max = info[1]["capacity"]
  46.   fluid = info[1]["contents"]["rawName"]
  47.   percfull = math.floor(stored/max*100)
  48.   percempty = 100 - math.ceil(stored/max*100)
  49.   usedheight = height - 20
  50.   hfull = 30 - math.floor(usedheight * (percfull/100))
  51.   hempty = hfull - math.ceil(usedheight * (percempty/100))
  52.   fill(3,48, hfull,31, colors.green)
  53.   fill(3,48, 21,hfull-1, colors.black)
  54.   writeat(19, percfull.."%")
  55. end
  56.  
  57. function main()
  58.   init()
  59.   while true do
  60.     energy()
  61.     --essence()
  62.     bridge.sync()
  63.     sleep(2)
  64.     bridge.clear()
  65.   end
  66. end
  67.  
  68. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement