Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("--------------------------------------")
- print("Tunnel program - Created by Mjmac85")
- print("Bridge materials in slot 1")
- print("Torches in slot 2")
- print("Fuel in slot 16")
- print("--------------------------------------")
- -- Make checks for all the items
- -- Torch placement works
- -- Length works
- -- return trip completed
- -- Args support
- -- Things to add - rednet support
- args = {...}
- if args[1] == nil then
- write("Length: ")
- local length = tonumber(read())
- end
- if args[1] ~= nil then
- length = tonumber(args[1])
- end
- local function fuel(currentSlot)
- while turtle.getFuelLevel() <= 5 do
- turtle.select(16)
- turtle.refuel(1)
- print(turtle.getFuelLevel())
- end
- turtle.select(currentSlot)
- end
- local function checkDown(currentSlot)
- if turtle.detectDown() == false then
- turtle.select(1)
- turtle.placeDown()
- turtle.select(currentSlot)
- end
- end
- --local function inventoryCheck()
- -- if turtle.getItemCount(14) > 0 then
- -- dropItems()
- -- end
- --end
- local function dropItems(distance, currentSlot)
- -- Returns back to chest area and drops items
- local selector = 3
- local back = 0
- --turns turtle around and heads back
- turtle.turnRight()
- turtle.turnRight()
- while back <= distance do
- fuel(currentSlot)
- turtle.forward()
- back = back + 1
- end
- --drops items into chest
- turtle.select(3)
- while selector <= 14 do
- turtle.select(selector)
- turtle.drop()
- selector = selector + 1
- end
- turtle.select(currentSlot)
- turtle.turnRight()
- turtle.turnRight()
- back = 0
- -- Heads back into the mine
- while back <= distance do
- fuel(currentSlot)
- turtle.forward()
- back = back + 1
- end
- end
- local function mine(currentSlot)
- fuel(currentSlot)
- while turtle.forward() == false do
- turtle.dig()
- end
- checkDown(currentSlot)
- turtle.digUp()
- end
- local function main()
- local fuelSlot = 16
- local currentSlot = 1
- local bridgeSlot = 1
- local torchSlot = 2
- local distance = 0
- local back = 0
- local selector = 3
- while distance <= length - 1 do
- fuel(currentSlot)
- turtle.select(fuelSlot)
- if turtle.getItemCount(14) > 0 then
- dropItems(distance, currentSlot)
- end
- mine(currentSlot)
- -- Torch Drop
- distance = distance + 1
- if distance % 8 == 0 then
- turtle.select(2)
- turtle.back()
- turtle.placeUp()
- turtle.forward()
- turtle.select(currentSlot)
- end
- -- end main distance loop
- end
- -- returns at the end
- turtle.turnRight()
- turtle.turnRight()
- while back <= distance do
- fuel(currentSlot)
- turtle.forward()
- back = back + 1
- end
- --drops items into chest
- turtle.select(3)
- while selector <= 14 do
- turtle.select(selector)
- turtle.drop()
- selector = selector + 1
- end
- turtle.select(currentSlot)
- turtle.turnRight()
- turtle.turnRight()
- -- end func
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment