Advertisement
SirBaconBitz

Ender IO Capacitor Monitor

Mar 10th, 2014
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. --Fetching Sides from File
  2. isset = fs.exists(".capacitordata")
  3. data = {}
  4.     --Saving variables to file
  5.     if isset == true then
  6.         handle = assert(fs.open(".capacitordata", "r"), "Couldn't load vars")
  7.         data = textutils.unserialize(handle.readAll())
  8.         handle.close()
  9.     elseif isset == false then
  10.         handle = assert(fs.open(".capacitordata", "w"), "Couldn't load vars")
  11.         term.clear()
  12.         term.setCursorPos(1,1)
  13.         term.write("Enter side of Advanced Monitor: ")
  14.         monitorside = read()
  15.         term.setCursorPos(1,2)
  16.         term.write("Enter side of Capacitor Bank: ")
  17.         capacitor = read()
  18.         data.capacitor = capacitor
  19.         data.monitorside = monitorside
  20.         handle.write(textutils.serialize(data))
  21.         handle.close()
  22.     end
  23.  
  24. --Wrapped monitor and Capacitor Bank as peripherals
  25. monitor = peripheral.wrap(data.monitorside)
  26. cap = peripheral.wrap(data.capacitor)
  27. monitor.clear()
  28.  
  29. --Infinite loop for Dynamic Data
  30. while true do
  31. monx, mony = monitor.getSize()
  32. stored = cap.getEnergyStored("1")
  33. maxstored = cap.getMaxEnergyStored("1")
  34. percent = math.ceil((stored / maxstored) * 100)
  35. pxpl = math.ceil(mony * (percent / 100))
  36. print(pxpl)
  37. sleep(1)
  38. term.redirect(monitor)
  39. paintutils.drawLine(monx,mony,0, 0,colors.black)
  40. term.restore()
  41. monitor.clear()
  42.     for i = 1, monx do
  43.         term.redirect(monitor)
  44.         paintutils.drawLine(i, mony, i, mony - pxpl, colors.green)
  45.         term.restore()
  46.         print(i)
  47.         print(mony)
  48.         print(pxpl)
  49.     end
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement