Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 3x3 tunnel script by cowslaw. (Nov. 29, 2015)
- -- Usage: tunnel <distance> <offset> <torch>.
- -- Arguments:
- -- distance: Distance turtle will dig.
- -- offset: Distance between starting point and start of tunnel.
- -- torch: How far apart torches are placed (default 10).
- -- Slottage:
- -- Slot 1: Fuel (preferably coal)
- -- Slot 2: Torches (optional)
- -- Variables (do not change):
- turtle.select(1)
- tArgs = { ... }
- if #tArgs ~= 3 then
- print("Usage:\n tunnel <distance> <offset> <torch>\n Edit for argument descriptions.")
- return
- end
- togo = tonumber(tArgs[1]) or 1
- offset = tonumber(tArgs[2]) or 0
- placement = (((tonumber(tArgs[3])) or 10) + 1) or 6
- torch = 0
- amount = 0
- percentage = 0
- outcome = 0
- -- Functions
- function digForward()
- checkFuel()
- repeat
- turtle.dig()
- sleep(0.25)
- until turtle.detect() == false
- checkFront()
- end
- function checkFuel()
- if turtle.getFuelLevel() <= 500 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- function turnAround()
- turtle.turnRight()
- turtle.turnRight()
- end
- function checkTopBottom()
- if turtle.detectUp() then
- turtle.digUp()
- end
- if turtle.detectDown() then
- turtle.digDown()
- end
- end
- function checkFront()
- if turtle.forward() == false then
- repeat
- turtle.attack()
- turtle.dig()
- sleep(0.25)
- until turtle.forward() == true
- end
- end
- function checkInventoryFull(currentDistance)
- if turtle.getItemCount(16) > 0 then
- turnAround()
- for b = 1, currentDistance do
- checkFuel()
- checkFront()
- end
- for e = 3, 16 do
- turtle.select(e)
- turtle.dropDown()
- end
- turnAround()
- for b = 1, currentDistance do
- checkFuel()
- checkFront()
- end
- end
- end
- -- Main Script
- checkFuel()
- if offset > 0 then
- for o = 1, offset do
- turtle.forward()
- end
- end
- for i = 1, togo do
- amount = amount + 1
- torch = torch + 1
- percentage = percentage + 1
- outcome = percentage / togo * 100
- term.clear()
- term.setCursorPos(1, 1)
- print("On block " .. amount .. " of " .. togo .. ".")
- print(math.floor(outcome, 3) .. "% complete.")
- checkFuel()
- digForward()
- checkTopBottom()
- turtle.turnRight()
- digForward()
- checkTopBottom()
- turnAround()
- checkFront()
- digForward()
- checkTopBottom()
- turnAround()
- checkFront()
- turtle.turnLeft()
- if torch == placement then
- turtle.select(2)
- turtle.down()
- turnAround()
- turtle.place()
- turnAround()
- turtle.up()
- turtle.select(1)
- torch = 0
- end
- checkInventoryFull((offset + amount))
- outcome = 0
- end
- turnAround()
- for b = 1, (togo + offset) do
- checkFuel()
- checkFront()
- end
- for e = 3, 16 do
- turtle.select(e)
- turtle.dropDown()
- end
- turnAround()
- print("Tunnel finished.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement