Skip to content

Instantly share code, notes, and snippets.

@MacChuck
Last active October 25, 2023 23:27
Show Gist options
  • Save MacChuck/943ec566fdf0ffa10321975006eea258 to your computer and use it in GitHub Desktop.
Save MacChuck/943ec566fdf0ffa10321975006eea258 to your computer and use it in GitHub Desktop.
Turtle Bubble Elevator
depth = 0
slotFill = 1
slotKelp = 5
slotGate = 9
slotDirt = 10
slotSoul = 11
slotWater = 12
print("Builds a bubblevator. Face turtle at fence gate direction. Water ends up one block forward from turtle's current position.")
print("Slot 1-4: filler block")
print("Slot 5-8: kelp")
print("Slot 9: 2x fence gates")
print("Slot 10: dirt")
print("Slot 11: soul sand")
print("Slot 12: water bucket")
--get height
print("Bubblevator depth?: ")
depth = tonumber(read())
function selectFiller()
if turtle.getItemCount(slotFill) == 0 then
if slotFill == 4 then
slotFill = 13 --out of filler blocks, use what is being dug up
else
slotFill = slotFill + 1
end
end
turtle.select(slotFill)
end
function checkWalls()
selectFiller()
turtle.forward()
turtle.turnLeft() selectFiller() turtle.place()
turtle.turnRight() selectFiller() turtle.place()
turtle.turnRight() selectFiller() turtle.place()
turtle.turnLeft()
turtle.back()
turtle.turnLeft() selectFiller() turtle.place()
turtle.turnLeft() selectFiller() turtle.place()
turtle.turnLeft() selectFiller() turtle.place()
turtle.turnLeft()
end
-- dig initial hole
for i = 1,depth do
turtle.select(13)
turtle.digDown()
if not turtle.down() then --hit bedrock
depth = i - 2 --adjust depth
print("Hit bedrock, new depth is "..depth)
turtle.up()
break
end
turtle.dig()
checkWalls()
end
-- move into water column spot and prep dirt for kelp
turtle.forward()
turtle.select(13)
turtle.digDown()
turtle.select(slotDirt)
turtle.placeDown()
-- place fence gates
for i = 1,depth do
if i < 3 then
turtle.dig()
turtle.select(slotGate)
turtle.place()
end
turtle.up()
end
--drop water
turtle.turnLeft()
turtle.turnLeft()
turtle.down()
turtle.select(slotWater)
turtle.placeDown()
-- move out of water
turtle.forward()
turtle.turnLeft()
turtle.turnLeft()
-- place kelp
for i = 1,depth-1 do
turtle.down()
end
for i = 1,depth do
if turtle.getItemCount(slotKelp) == 0 and slotKelp ~= 8 then
slotKelp = slotKelp + 1
end
turtle.select(slotKelp)
turtle.place()
turtle.up()
end
-- swap dirt for soul sand
for i = 1,depth do
turtle.down()
end
turtle.digDown()
turtle.down()
turtle.select(13)
turtle.dig()
turtle.select(slotSoul) --soulsand
turtle.place()
-- backfill work column
selectFiller()
turtle.up()
turtle.placeDown()
for i = 1,depth do
selectFiller()
turtle.up()
turtle.placeDown()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment