Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This program tells a turtle to tunnel forward by a specified amount.
- The tunnel will be 3 blocks tall, 1 block above and 1 block below the turtle.
- The turtle returns to the starting position.
- ]]
- --[[ Functions ]]
- local function fwd()
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.digUp()
- turtle.digDown()
- end
- local function enoughFuel(x)
- if turtle.getFuelLevel() < 2 * x then
- return false
- else
- return true
- end
- end
- --[[ Main ]]
- -- Query user
- print("How much in front of me would you like me to dig?")
- local x = read()
- -- Check for fuel
- if not enoughFuel(x) then
- print("Please refuel. I need at least " .. x * 2 .. " units for that job")
- return
- end
- -- Dig
- for i = 1, x do
- fwd()
- end
- -- Come back
- for i = 1, x do
- turtle.back()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement