Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Minecraft Computercraft Netherbridge Program
- -- Creates a 2 x 2 roofed tunnel with 1 block railing
- fuelLimit = 500
- args = {...}
- function forceDig(detectFunc, digFunc)
- while detectFunc() do
- digFunc()
- end
- end
- function fDig()
- forceDig(turtle.detect, turtle.dig)
- end
- function fDigUp()
- forceDig(turtle.detectUp, turtle.digUp)
- end
- function fDigDown()
- forceDig(turtle.detectDown, turtle.digDown)
- end
- function forcePlacement(detectFunc, digFunc, placeFunc)
- forceDig(detectFunc, digFunc)
- if turtle.getItemCount(turtle.getSelectedSlot()) > 0 and placeFunc() then
- return
- end
- for i = 1, 16, 1 do
- turtle.select(i)
- if turtle.getItemCount(i) > 0 then
- if placeFunc() then
- return
- end
- end
- end
- error("No more placeable blocks")
- end
- function fPlace()
- forcePlacement(turtle.detect, turtle.dig, turtle.place)
- end
- function fPlaceUp()
- forcePlacement(turtle.detectUp, turtle.digUp, turtle.placeUp)
- end
- function fPlaceDown()
- forcePlacement(turtle.detectDown, turtle.digDown, turtle.placeDown)
- end
- function fuel()
- local selectedSlot = turtle.getSelectedSlot()
- if turtle.getFuelLevel() <= fuelLimit then
- for i = 1, 16, 1 do
- turtle.select(i)
- turtle.refuel(64)
- if turtle.getFuelLevel() > fuelLimit then
- break
- end
- end
- end
- turtle.select(selectedSlot)
- end
- function main()
- -- Mine left corridor
- turtle.turnLeft()
- fDig()
- turtle.forward()
- fPlaceDown()
- fPlace()
- fDigUp()
- turtle.up()
- fPlaceUp()
- -- Back To starting position
- turtle.down()
- turtle.back()
- turtle.turnRight()
- -- Mine main block
- fPlaceDown()
- turtle.turnRight()
- fPlace()
- turtle.turnLeft()
- fDigUp()
- turtle.up()
- fPlaceUp()
- turtle.down()
- fDig()
- turtle.forward()
- fuel()
- end
- -- Arg 1 can be used to set tunnel length
- if #(args) < 1 then
- while true do
- main()
- end
- else
- for i=0,args[1],1 do
- main()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment