Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs ~= 1 then
- print( "Usage: cast <length>" )
- return
- end
- local j = 2
- local i = 0
- -- 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
- --Finds an inventory slot with a block that is not slot 1
- findSlot = function()
- while turtle.getItemCount(j) == 0 do
- if j < 16 then
- j = j+1
- else
- print("Out of blocks")
- end
- end
- turtle.select(j)
- 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)
- findSlot()
- end
- end
- buildBridge = function(length)
- while i < length do
- placeBlocks()
- end
- turtle.turnRight()
- turtle.turnRight()
- for x=1,length do
- turtle.forward()
- end
- end
- placeBlocks = function()
- if not turtle.detectUp() then
- findSlot()
- turtle.placeUp()
- end
- turtle.turnLeft()
- if not turtle.detect() then
- findSlot()
- turtle.place()
- end
- turtle.turnRight()
- turtle.turnRight()
- if not turtle.detect() then
- findSlot()
- turtle.place()
- end
- turtle.turnLeft()
- forwardCheck()
- i = i + 1
- turtle.turnRight()
- if not turtle.detect() then
- findSlot()
- turtle.place()
- end
- turtle.turnRight()
- if not turtle.detect() then
- findSlot()
- turtle.place()
- end
- turtle.turnRight()
- if not turtle.detect() then
- findSlot()
- turtle.place()
- end
- turtle.turnRight()
- forwardCheck()
- i = i + 1
- turtle.turnRight()
- if not turtle.detect() then
- findSlot()
- turtle.place()
- end
- turtle.turnRight()
- turtle.turnRight()
- if not turtle.detect() then
- findSlot()
- turtle.place()
- end
- turtle.turnRight()
- forwardCheck()
- i = i + 1
- end
- buildBridge(tonumber(tArgs[1]))
Add Comment
Please, Sign In to add comment