Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function checkFuel()
- if turtle.getFuelLevel() < 16 then
- turtle.refuel()
- end
- end
- local function moveForward(steps)
- for i=1, steps do
- turtle.forward()
- checkFuel()
- sleep(0)
- end
- end
- local function digForward()
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- turtle.digDown()
- checkFuel()
- sleep(0)
- end
- local function printUsages()
- print("Usages:")
- print("mine hollow <squareSize>")
- print("mine strip <innerSquareSize> <totalSize>")
- end
- local tArgs = { ... }
- if #tArgs < 1 then
- printUsages()
- return
- end
- local function digInnerStripSquare(size)
- for direction = 1, 4 do
- for i=1,size-1 do
- digForward()
- end
- turtle.turnRight()
- end
- moveForward(size-1)
- end
- local function moveBackward(steps)
- for i=1, steps do
- turtle.back()
- checkFuel()
- sleep(0)
- end
- end
- local function digStripSquare(inner, repetitions)
- for j = 1, repetitions do
- for i=1, repetitions do
- digInnerStripSquare(inner)
- end
- turtle.turnRight()
- moveForward(inner - 1)
- turtle.turnLeft()
- moveBackward((inner -1) * repetitions)
- end
- turtle.turnRight()
- moveBackward((inner -1) * repetitions)
- turtle.turnLeft()
- end
- local function digHollowSquare(size)
- for j = 1, size do
- for i=1, size-1 do
- digForward()
- end
- if j < size then
- if j % 2 == 0 then
- turtle.turnLeft()
- digForward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- digForward()
- turtle.turnRight()
- end
- sleep(0)
- end
- end
- if size % 2 == 0 then
- turtle.turnLeft()
- for i=1, size-1 do
- turtle.back()
- checkFuel()
- sleep(0)
- end
- turtle.turnLeft()
- else
- turtle.turnRight()
- for i=1, size-1 do
- turtle.back()
- checkFuel()
- sleep(0)
- end
- turtle.turnLeft()
- for i=1, size-1 do
- turtle.back()
- checkFuel()
- sleep(0)
- end
- end
- end
- local sCommand = tArgs[1]
- if sCommand == "hollow" then
- digHollowSquare(tonumber(tArgs[2]))
- elseif sCommand == "strip" then
- digStripSquare(tonumber(tArgs[2]), math.ceil(tonumber(tArgs[3])/tonumber(tArgs[2])))
- else
- printUsages()
- end
Add Comment
Please, Sign In to add comment