Advertisement
VaMinion

Ender Chest Discharger

Apr 5th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. -- Ghetto tesseract part 2: Discharging.
  2. -- Needs to be run in parallel with another turtle running part 1.
  3. -- Use with thermal expansion energy cells.
  4. -- Place Ender Chest above the turtle and the energy cell below. Make sure the cell plugs into something that will charge it.
  5. -- Configure all sides of the energy cell to be output, bottom to be input.
  6.  
  7. -- Sleep to avoid overlapping grabs.
  8. os.sleep(1)
  9.  
  10. function discharge ()
  11.  -- Wrap the peripheral
  12.  battery = peripheral.wrap("bottom")
  13.  -- This charges the energy cell
  14.  while battery.getEnergyStored() > 0 do
  15.   print("Energy at "..battery.getEnergyStored()..". Picking up.")
  16.   os.sleep(2)
  17.  end
  18.  -- Now pick up the cell and put it into the ender chest.
  19.  turtle.digDown()
  20.  turtle.dropUp()
  21.  os.sleep(10)
  22. end
  23.  
  24. function place_for_discharge()
  25.  -- Take the empty cell from the chest and put it down for recharge
  26.  while not turtle.suckUp() do
  27.   os.sleep(2)
  28.  end
  29.  turtle.placeDown()
  30. end
  31.  
  32. function main()
  33.  while true do
  34.    if turtle.detectDown() then
  35.     discharge()
  36.    else
  37.     place_for_discharge()
  38.    end
  39.  end
  40. end
  41.  
  42. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement