Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs ~= 1 then
- print( "Usage: bridge <length>" )
- return
- end
- -- Initial Fueling
- turtle.refuel(1)
- -- variable to tell main function when to stop
- local o = 1
- -- Function to get the fuel level of the robot as a number
- fcount = function()
- return turtle.getFuelLevel()
- end
- -- Move forward, Fuel Check and Refuel function
- forwardCheck = function()
- turtle.forward()
- if fcount() < 1 then
- turtle.select(1)
- print ("Attempting to eat my fuel...")
- if turtle.getItemCount(1) < 1 then
- print ("I am out of fuel...")
- o = 0
- end
- turtle.refuel(1)
- turtle.select(2)
- end
- end
- buildBridge = function(length)
- local i = 0
- while i < length do
- placeBlocks()
- while turtle.detect() do
- turtle.attack()
- turtle.attackUp()
- turtle.dig()
- end
- forwardCheck()
- i = i + 1
- end
- turtle.turnRight()
- turtle.turnRight()
- for i=1,length do
- turtle.forward()
- end
- end
- placeBlocks = function()
- if not turtle.detectDown() then
- turtle.select(2)
- turtle.placeDown()
- end
- turtle.turnLeft()
- if not turtle.detect() then
- turtle.select(2)
- turtle.place()
- end
- turtle.turnRight()
- turtle.turnRight()
- if not turtle.detect() then
- turtle.select(2)
- turtle.place()
- end
- turtle.turnLeft()
- end
- buildBridge(tonumber(tArgs[1]))
Advertisement
Add Comment
Please, Sign In to add comment