Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- #########################
- -- Frame Filler (for a flooring work)
- -- version0.1
- -- http://hevohevo.hatenablog.com/
- -- 1. Build a frame for a flooring work
- -- The frame must be a rectangle
- -- 2. Set the turtle on the frame-block as follows;
- -- Top view
- -- T: turtle, f: frame-blocks (e.g., stone-brick)
- -- fffffffffffffffffffff
- -- f f
- -- f f
- -- fTfffffffffffffffffff
- -- 3. Insert Frame-blocks (stone-brick) into turtle's slot 15
- -- for detecting a boundary line
- -- 4. Slot 1-14 are used for filling blocks
- -- 5. Run this program
- FRAME = 15
- FUEL = 16
- function select_block(slot)
- slot = slot or turtle.getSelectedSlot()
- if turtle.getItemCount(slot) == 0 then
- if slot < 14 then
- select_block(slot+1)
- else
- error("Item empty: insert slots 1-14.")
- end
- else
- turtle.select(slot)
- end
- end
- function detect_frame()
- local tmp_slot = turtle.getSelectedSlot()
- turtle.select(FRAME)
- local status, err = turtle.compareDown()
- turtle.select(tmp_slot)
- return status, err
- end
- -- main
- turtle.select(1)
- local count = 0
- while true do
- turtle.forward()
- if detect_frame() then
- count = count +1
- turtle.back()
- turtle.turnRight()
- if count > 2 then break end
- else
- count = 0
- select_block()
- turtle.placeDown()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement