Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = "1.4"
- local torchDistance = 10
- local torchCount = 1
- local turn = ""
- local gate = peripheral.wrap("right")
- local function doScreen(str)
- term.clear()
- term.setCursorPos(1,1)
- write("Redstone Cell Turtle - v")
- print(version)
- print("------------------------------")
- write("Fuel: ")
- print(turtle.getFuelLevel())
- print()
- print(str)
- end
- local function swapCells()
- doScreen("Getting fresh redstone cell from base...")
- turtle.select(1)
- turtle.transferTo(14)
- turtle.select(16)
- turtle.digDown()
- turtle.transferTo(1)
- turtle.select(1)
- while turtle.getItemCount(1) > 0 do
- redstone.setOutput("front",true)
- os.sleep(0.2)
- redstone.setOutput("front",false)
- os.sleep(0.2)
- end
- while turtle.getItemCount(1) == 0 do
- os.sleep(0.2)
- end
- turtle.placeDown()
- redstone.setOutput("front",true)
- while not redstone.getInput("front") do
- os.sleep(0.2)
- end
- turtle.select(14)
- turtle.transferTo(1)
- turtle.select(1)
- doScreen("New redstone cell deployed.")
- end
- local function doTorch()
- torchCount = torchCount + 1
- if torchCount > torchDistance then
- torchCount = 1
- turtle.select(15)
- turtle.placeUp()
- end
- end
- local function fill()
- local i = 1
- while turtle.getItemCount(i) == 0 and i < 15 do
- i = i + 1
- end
- if i < 15 then
- turtle.select(i)
- turtle.placeDown()
- end
- end
- doScreen("Place items as follows...")
- print("--------------------------")
- print("| Torches in 15 (optional)")
- print("| Redstone Cell in 16")
- print("| Fill rest with cobble (optional)")
- while (turtle.getItemCount(16)==0) do
- os.sleep(0.2)
- end
- redstone.setOutput("front",true)
- doScreen("Waiting for lead turtle...")
- while not redstone.getInput("front") do
- os.sleep(0.1)
- end
- turtle.select(16)
- turtle.placeDown()
- while true do
- doScreen("Powering...")
- doTorch()
- while redstone.getInput("front") do
- if gate.get()["No Energy"] then
- swapCells()
- end
- os.sleep(0.5)
- end
- doScreen("Moving...")
- turtle.select(16)
- turtle.digDown()
- fill()
- redstone.setOutput("front",false)
- while not turtle.forward() do
- os.sleep(0.1)
- end
- turtle.select(16)
- turtle.placeDown()
- while not redstone.getInput("front") do
- doScreen("Searching for lead turtle...")
- turtle.turnRight()
- end
- redstone.setOutput("front",true)
- end
Advertisement
Add Comment
Please, Sign In to add comment