Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t = turtle
- function moveForward()
- if t.detect() then
- t.dig()
- t.forward()
- else
- t.forward()
- end
- end
- function fuelTurtle(distance)
- t.refuel(distance/80)
- end
- function moveDistance(distance)
- while distance > 0 do
- moveForward()
- distance = distance - 1
- end
- end
- function distanceInput()
- num = io.read()
- num = tonumber(num)
- return num
- end
- function turnAround()
- t.turnLeft()
- t.turnLeft()
- end
- function moveUp()
- if t.detectUp() then
- t.digUp()
- t.up()
- else
- t.up()
- end
- end
- function main()
- distance = distanceInput()
- fuelTurtle(distance)
- moveDistance(distance)
- t.refuel(1)
- moveUp()
- turnAround()
- fuelTurtle(distance)
- moveDistance(distance)
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement