Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = { ... }
- garbage = {
- "minecraft:cobblestone",
- "minecraft:dirt",
- "minecraft:gravel",
- "minecraft:diorite",
- "minecraft:andesite",
- "minecraft:granite",
- "chisel:marble",
- }
- function digForward()
- while turtle.detect() do
- turtle.dig()
- end
- end
- function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- function digDown()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- function forward(count)
- for i = 1, count do
- digForward(1)
- while not turtle.forward() do
- digForward(1)
- turtle.attack()
- end
- end
- end
- function up(count)
- for i = 1, count do
- digUp(1)
- while not turtle.up() do
- digUp(1)
- turtle.attackUp()
- end
- end
- end
- function down(count)
- for i = 1, count do
- digDown(1)
- while not turtle.down() do
- digDown(1)
- turtle.attackDown()
- end
- end
- end
- function turnLeft(count)
- for i = 1, count do
- turtle.turnLeft()
- end
- end
- function turnRight(count)
- for i = 1, count do
- turtle.turnRight()
- end
- end
- function dig3x3InFront()
- forward(1)
- turnLeft(1)
- for i = 1, 2 do
- digForward(1)
- up(1)
- end
- digForward(1)
- turnRight(2)
- for i = 1, 2 do
- digForward(1)
- down(1)
- end
- digForward(1)
- turnLeft(1)
- end
- function isGarbage(val)
- for index, value in ipairs(garbage) do
- if value == val then
- return true
- end
- end
- return false
- end
- function checkForAndDropGarbage()
- for i = 1, 16 do
- local data = turtle.getItemDetail(i)
- if data then
- if isGarbage(data.name) then
- turtle.select(i)
- turtle.drop()
- end
- end
- end
- turtle.select(1)
- end
- function digLoop(length)
- for i = 1, length do
- dig3x3InFront()
- end
- checkForAndDropGarbage()
- turtle.back()
- turnRight(1)
- forward(1)
- dig3x3InFront()
- dig3x3InFront()
- dig3x3InFront()
- turtle.back()
- turnRight(1)
- forward(1)
- for i = 1, length do
- dig3x3InFront()
- end
- checkForAndDropGarbage()
- turtle.back()
- turnLeft(1)
- forward(1)
- dig3x3InFront()
- dig3x3InFront()
- dig3x3InFront()
- turtle.back()
- turtle.turnLeft(1)
- forward(1)
- end
- function refuel()
- for i=1,16 do
- turtle.select(i);
- turtle.refuel()
- end
- end
- function dropAll()
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- end
- if table.getn(args) ~= 2 then
- print("arguments 'width' and 'depth' expected (width is multiplied by 3)")
- else
- local x = tonumber(args[1])
- local y = tonumber(args[2]) - 2
- for j = 1, x do
- digLoop(y)
- refuel()
- if turtle.getItemCount(10) > 0 then
- checkForAndDropGarbage()
- turnLeft(1)
- forward(6 * j)
- dropAll()
- turnLeft(2)
- forward(6 * j)
- turnLeft(1)
- end
- end
- checkForAndDropGarbage()
- turnLeft(1)
- forward(6 * x)
- dropAll()
- turnRight(1)
- end
Add Comment
Please, Sign In to add comment