Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t = turtle
- function distanceInput()
- print("Input Distance")
- num = io.read
- num = tonumber(num)
- return num
- end
- function hole(distance)
- while distance > 0 do
- if t.detectDown() then
- t.digDown()
- t.down()
- else
- t.down()
- distance = distance - 1
- end
- end
- function modulo(tile)
- while tile > 8 do
- tile = tile - 8
- end
- print("Currently at tile: ", tile)
- return tile
- end
- function turn(num)
- while num > 0 do
- t.turnRight()
- num = num - 1
- end
- end
- function turnAround()
- t.turnLeft()
- t.turnLeft()
- end
- function dleft()
- t.turnLeft()
- if t.detect() then
- t.dig()
- t.forward()
- else
- t.forward()
- end
- t.turnRight()
- end
- function dright()
- t.turnRight()
- if t.detect() then
- t.dig()
- t.forward()
- else
- t.forward()
- end
- t.turnLeft()
- end
- function dback()
- turnAround()
- if t.detect() then
- t.dig()
- t.forward()
- else
- t.forward()
- end
- turnAround()
- end
- function bforward()
- if t.detect() then
- t.dig()
- t.forward()
- else
- t.forward()
- end
- end
- function mineLayer(module)
- if module == 2 or module == 4 or module == 6 or module == 8 then
- turn(module/2)
- dleft()
- dforward()
- dback()
- dback()
- dright()
- dright()
- dforward()
- dforward()
- dback()
- dleft()
- else
- turn((module+1)/2)
- dforward()
- dright()
- dback()
- dback()
- dleft()
- dleft()
- dforward()
- dright()
- end
- end
- function mine(distance)
- module = 0
- while distance > 0 do
- module = modulo(distance)
- mineLayer(module)
- t.up()
- distance = distance - 1
- end
- end
- function spiral()
- distance = distanceInput()
- print("3x3 Spiral Initiated; No further input required")
- hole(distance)
- mine(distance)
- end
Add Comment
Please, Sign In to add comment