Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Redstone Energy Cell Charger
- -- Top ender chest is for Empty cells
- -- Bottom chest is for Full cells
- p = peripheral.wrap("front") -- Cell management
- function checkCell()
- -- See if a cell is in front of the turtle, and if it is charged.
- print("Checking for cell")
- cellPresent = turtle.detect()
- if cellPresent == true then
- print("Cell present")
- if p.getEnergyStored("front") == p.getMaxEnergyStored("front") then
- print("Cell fully charged - swapping")
- swapCell()
- else print("Cell not fully charged")
- end
- end
- if cellPresent == false then
- print("No cell detected, placing new cell")
- swapCell()
- end
- end
- function getEmptyCell()
- -- check if there's a cell in inventory, if not, grab one
- if turtle.getItemCount(1) == 0 then turtle.suckUp() end -- pull cell from depleted chest
- return true
- end
- function swapCell()
- print("Swapping cell")
- turtle.dig()
- turtle.dropDown()
- turtle.suckUp()
- turtle.place()
- return true
- end
- while true do
- --check for cell
- -- if present, check charge level - if full, cycle, if not, wait
- checkCell()
- print("Round complete, sleeping for 30 seconds.")
- sleep(30) -- wait 30 seconds for next check.
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement