Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs ~= 2 then
- print( "Usage: bridge <length> <direction of landmark (L, R, B)>" )
- 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 then
- -- 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
- -- Place Landmark in front
- function placelm()
- if tArgs[2] == "R" then
- if not (turtle.detect()) then
- turtle.turnRight()
- turtle.forward()
- turtle.select(9)
- turtle.placeDown()
- turtle.back()
- turtle.select(10)
- turtle.place()
- turtle.turnLeft()
- end
- end
- if tArgs[2] == "L" then
- if not (turtle.detect()) then
- turtle.turnLeft()
- turtle.forward()
- turtle.select(9)
- turtle.placeDown()
- turtle.back()
- turtle.select(10)
- turtle.place()
- turtle.turnRight()
- end
- end
- if tArgs[2] == "B" then
- if not (turtle.detect()) then
- turtle.turnRight()
- turtle.forward()
- turtle.select(9)
- turtle.placeDown()
- turtle.back()
- turtle.select(10)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.select(9)
- turtle.placeDown()
- turtle.back()
- turtle.select(10)
- turtle.place()
- turtle.turnRight()
- end
- end
- end
- function backhome()
- x = length
- while x > 0 do
- -- putblockdown()
- turtle.back()
- x = x - 1
- end
- end
- -- Move forward <length> times
- -- and build a bridge with
- -- blocks provided in slot 9
- local i = 0
- while i < length do
- -- putblockdown()
- turtle.forward()
- i = i + 1
- end
- placelm()
- backhome()
- -- That's all, folks!
- print("Built a bridge "..i.." blocks long")
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement