Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --note to self: metadata - block, damage - item
- function compareBlocks(data1, data2)
- return (data1.name == data2.name and data1.metadata == data2.metadata)
- end
- function damageToMetadata(data)
- return {name = data.name, metadata = data.damage}
- end
- function selectItem(name)
- for i = 1, 16 do
- turtle.select(i)
- if turtle.getItemCount() > 0 then
- if turtle.getItemDetail().name == name then
- return true
- end
- end
- end
- return false
- end
- function breakAllAbove()
- while turtle.detectUp() do
- turtle.digUp()
- turtle.up()
- end
- while not turtle.detectDown() do
- turtle.down()
- end
- end
- function compareDown(compareData)
- local success, data = turtle.inspectDown()
- return (data.name == compareData.name and data.metadata == compareData.metadata)
- end
- local arg = {...}
- turtle.select(1)
- local block = damageToMetadata(turtle.getItemDetail())
- local size = tonumber(arg[1])
- turtle.dig()
- turtle.forward()
- for y = 1, size do
- for x = 1, size do
- if not compareDown(block) then
- turtle.digDown()
- selectItem(block.name)
- turtle.placeDown()
- end
- breakAllAbove()
- if x < size then
- turtle.dig()
- turtle.forward()
- end
- end
- if y < size then
- local direction = (y % 2 == 0)
- if direction then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- turtle.dig()
- turtle.forward()
- if direction then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement