Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = 1.1
- -- +------------------------+ --
- -- |--> INITIALIZATION <--| --
- -- +------------------------+ --
- if not turtle or not turtle.forceForward then
- print("This program can only be")
- print("executed by a turtle")
- print("with BetterTurtle API.")
- return
- end
- -- UPDATE HANDLING --
- if _UD and _UD.su(version, "5V85iVAM", {...}) then return end
- 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
Advertisement