Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --File: /placeBlocks
- dofile("/cattech/common.lua")
- function placeBlockEveryX(mvFwd,itemList)
- local continue=true
- while continue do
- refuelIfNeeded(10)
- local placeItem = selectTurtleItemByList(itemList)
- if (placeItem) then
- if placeItemByList(itemList,"down") then
- -- print("Placed")
- else
- print("Could not place " .. table.concat(itemList))
- end
- for i = 1, mvFwd do
- if turtle.detect() then
- print("Obstacle detected! Stopping.")
- continue = false
- else
- turtle.forward()
- end
- end
- else
- print("Out of item " .. table.concat(itemList))
- continue = false
- end
- end
- end
- -- Main program
- if #arg < 1 then
- print("Usage: placeBlocks <number_of_spaces>")
- else
- local spaces = tonumber(arg[1]) -- Get the first argument
- local itemDetail = turtle.getItemDetail(1)
- if itemDetail then
- local itemList = {itemDetail.name};
- print("Placing : " .. table.concat(itemList))
- placeBlockEveryX(spaces,itemList) -- Call the function with the given spaces
- else
- print("No item in slot 1, stopping!")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement