Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Programmed: 17 May 2014
- -- by Skyler James
- --
- -- Builds a bridge <length>
- -- blocks long, 1 block wide
- --
- -- The blocks to be used in
- -- the bridge MUST be placed
- -- in slot 9. There is error
- -- checking to ensure this.
- --
- -- Turtle will NOT break any
- -- blocks in its way
- local tArgs = { ... }
- if #tArgs ~= 1 then
- print( "Usage: bridge <length>" )
- return
- end
- -- Set length with user input
- local length = tonumber( tArgs[1] )
- if length < 1 then
- print( "Bridge length must be positive" )
- return
- end
- -- Check that there are <length>
- -- blocks provided in slot 9
- local numblocks = turtle.getItemCount(9)
- if numblocks < length
- print("Please place at least "..length.." building blocks in slot 9")
- return
- end
- -- Place a block underneath
- -- the turtle to build bridge
- function putblockdown()
- if not (turtle.detectDown()) then
- turtle.select(9)
- turtle.placeDown()
- end
- end
- -- Move forward <length> times
- -- and build a bridge with
- -- blocks provided in slot 9
- local i = 0
- for i,length,1 do
- if (turtle.detect()) then
- break
- else
- putblockdown()
- turtle.forward()
- end
- end
- -- That's all, folks!
- print("Built a bridge "..i.." blocks long")
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement