Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local en = ... -- get input. If there is any input, move down instead of up
- local et
- -- find the first block in inventory, select it.
- local function find()
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- return
- end
- end
- -- if nothing found, error.
- error("We have run out of items.", 0)
- end
- -- make turtle.place/etc find the item before placing each time.
- function turtle.place()
- find()
- return turtle.native.place()
- end
- function turtle.placeDown()
- find()
- return turtle.native.placeDown()
- end
- function turtle.placeUp()
- find()
- return turtle.native.placeUp()
- end
- -- if input, go down, else up
- if en then
- en = turtle.down
- et = turtle.placeUp
- else
- en = turtle.up
- et = turtle.placeDown
- end
- local fails = 0
- while true do
- turtle.place() -- place
- if turtle.back() then
- fails = 0 -- if we went back, reset fails to 0
- else
- turtle.turnRight() -- if we failed to move back, turn and increase fails
- fails = fails + 1
- end
- if fails > 3 then
- en() -- if we've turned 4 times, go up/down, then place a block there
- et()
- break
- end
- end
- -- reset turtle funcs
- turtle.place = turtle.native.place
- turtle.placeDown = turtle.native.placeDown
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement