Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("tmnt")
- local currentSlot = 0
- local blockPlaced = 0
- local requiredQuantity = 0
- function turnForNext(x)
- if x % 2 == 0 then
- turtle.turnLeft()
- else
- turtle.turnRight()
- end
- end
- function checkQuantity()
- sum = 0
- for i = 1, 16 do
- sum = sum + turtle.getItemCount(i)
- end
- local qty = requiredQuantity - blockPlaced
- if sum < qty then
- print("Not enough blocks")
- print("Got: "..sum)
- print("Need: "..requiredQuantity)
- tmnt.pause("Please insert some blocks in the turtle")
- checkQuantity()
- end
- end
- function findNextBlock()
- currentSlot = currentSlot + 1
- while currentSlot <= 16 do
- if turtle.getItemCount(currentSlot) > 0 then
- turtle.select(currentSlot)
- return
- end
- currentSlot = currentSlot + 1
- end
- checkQuantity()
- end
- function main(width, depth)
- tmnt.checkFuel()
- requiredQuantity = width * depth
- checkQuantity()
- turtle.select(1)
- currentSlot = 1
- tmnt.forceUp()
- for x = 1, width do
- for y = 1, depth do
- if turtle.getItemCount(currentSlot) == 0 then
- findNextBlock()
- end
- tmnt.tryPlaceDown()
- blockPlaced = blockPlaced + 1
- if y < depth then
- tmnt.forceForward()
- end
- end
- if x < width then
- turnForNext(x)
- tmnt.forceForward()
- turnForNext(x)
- else
- turnForNext(x + 1)
- end
- end
- end
- --------------------
- -- Argument parser
- --------------------
- local argv = { ... }
- if #argv ~= 2 then
- error("Usage: floor <width> <depth>")
- end
- local width = tonumber(argv[1])
- local depth = tonumber(argv[2])
- main(width, depth)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement