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 moveUpward()
- if t.detectUp() then
- t.digUp()
- t.up()
- else
- t.up()
- end
- end
- function fuelTurtle(distance)
- t.refuel(distance/80)
- end
- function moveDistanceForward(distance)
- while distance > 0 do
- moveForward()
- distance = distance - 1
- end
- end
- function moveDistanceUpward(distance)
- while distance > 0 do
- moveUpward()
- 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 shaft()
- print("Input distance: ")
- distance = distanceInput()
- fuelTurtle(distance)
- moveDistanceForward(distance)
- t.refuel(1)
- moveUp()
- turnAround()
- fuelTurtle(distance)
- moveDistance(distance)
- end
- function hole()
- print("Input distance: ")
- distance = distanceInput()
- fuelTurtle(distance)
- function main()
- print("1 = Shaft, 2 = Hole")
- func = io.read()
- func = tonumber(func)
- if func == 1 then
- shaft()
- elif func == 2 then
- hole()
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment