Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dim = 16
- local totalBlocks = 0
- local selection = 1
- local outOfBlocks = false
- turtle.select(1)
- function setTotalBlocks()
- local count = 1
- while ( count <= 15 and turtle.getItemCount(count) > 1) do
- totalBlocks = count
- count = count + 1
- end
- end
- function selectBlock()
- if ( outOfBlocks ) then return false end
- if ( turtle.getItemCount(selection) < 1 ) then
- if ( selection >= totalBlocks ) then
- outOfBlocks = true
- return false -- out of placeable blocks
- end
- selection = selection + 1
- turtle.select(selection)
- end
- return true
- end
- function checkSpace()
- if ( selectBlock() ) then
- if ( turtle.compareDown() == false ) then
- local needNewBlock = ( turtle.getItemCount(selection) == 1 )
- turtle.digDown()
- if ( outOfBlocks == false ) then turtle.placeDown() end
- if ( needNewBlock ) then
- if ( selection < totalBlocks ) then
- selection = selection + 1
- turtle.select(selection)
- else
- outOfBlocks = true
- end
- end
- end
- else
- turtle.select(16)
- if ( turtle.compareDown() == false ) then turtle.digDown() end
- end
- end
- function forward()
- if ( turtle.forward() == false ) then
- repeat
- os.sleep(3)
- until ( turtle.forward() == true )
- end
- end
- function checkAllTiles()
- local x,y = 0,0
- for x = 1,dim do
- for y = 1,dim do
- checkSpace()
- forward()
- end
- if ( x % 2 == 0 ) then
- turtle.turnLeft()
- forward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- forward()
- turtle.turnRight()
- end
- forward()
- end
- end
- if ( turtle.detectDown() ) then turtle.up() end
- setTotalBlocks()
- while true do
- checkAllTiles()
- turtle.turnLeft()
- forward()
- os.Sleep(60)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement