Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Turtle will move forward and to the right.
- -- Turtle will build below itself.
- arg = {...}
- length = tonumber(arg[1])
- width = tonumber(arg[2])
- currentSlot = 1
- processMore = true
- -- Usage
- if (length == nil or width == nil) then
- print ("Usage: Program <length> <width>")
- print ("Length = Blocks forward.")
- print ("Width = Blocks to the right.")
- return
- end
- -- Checks if the turtle slot is empty
- -- Going from slot to 16 wrapping (1 - 16)
- function slotEmpty()
- for i=0,16,1 do
- newSlot = ((currentSlot + i) % 16) + 1
- if (turtle.getItemCount(newSlot) ~= 0) then
- currentSlot = newSlot
- turtle.select(newSlot)
- print("\nFound a block at ".. newSlot .. " carry on")
- return true
- end
- end
- print("\nI've run out of blocks, I will wait for more.")
- return false
- end
- for i=0,(width - 1),1 do
- for j=1,(length - 1),1 do
- processMore = slotEmpty()
- if processMore then
- turtle.forward()
- turtle.placeDown()
- end
- end
- if not processMore then
- print("I have run out of blocks to place, I will wait for more.")
- break
- end
- if (i % 2 == 0) then
- if (i ~= width - 1) then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- else
- if (i ~= width - 1) then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- end
- -- See if we have an item in any slot, if we do, then place it
- -- if we don't have any items, then we break out of the loop, cause we're done
- processMore = slotEmpty()
- if processMore then
- turtle.placeDown()
- else
- break
- end
- end
- print("\nMy programming indicates that the floor is completed.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement