Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ARGS = {...}
- turtle.select(1)
- -- convenience functions
- local function nextSlot()
- turtle.select(turtle.getSelectedSlot()+1)
- end
- local function empty()
- return turtle.getItemCount() == 0
- end
- local function build()
- turtle.placeDown()
- if empty() then nextSlot() end
- turtle.forceForward()
- end
- -- MAIN
- if not empty() then
- -- build fence
- local w = tonumber(ARGS[1])
- local l = tonumber(ARGS[2])
- turtle.forceUp()
- for i=2,l do build() end
- turtle.turnRight()
- for i=2,w do build() end
- turtle.turnRight()
- for i=2,l do build() end
- turtle.turnRight()
- for i=2,w do build() end
- else
- -- take down fence
- while turtle.detect() do
- while turtle.detect() do
- turtle.forceForward()
- end
- turtle.turnRight()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment