Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Author
- Rasmus Sommer aka. TheSommer
- youtube.com/thesommersmc
- twitch.tv/thesommer
- How to use:
- Slot 1 - Fuel
- Slot 2 - (OPTIONAL) Torches
- mineshaft <param: right | left>
- OPTIONAL parameters: right OR left
- This program uses optional parameters.
- You don't HAVE to write something after the program name,
- but if you write "right" or "left" the turtle will place torches to the specified side.
- --]]
- local tArgs = { ... }
- local side = "NA"
- if #tArgs == 0 then
- elseif #tArgs == 1 then
- if tArgs[1] == "right" then
- side = "right"
- elseif tArgs[1] == "left" then
- side = "left"
- else
- print ("Usage: mineshaft <param>")
- print ("OPTIONAL parameters: right OR left")
- print ("--- Using parameters will make the turtle place torches! ---")
- end
- else
- print ("Usage: mineshaft <param>")
- print ("OPTIONAL parameters: right OR left")
- print ("--- Using parameters will make the turtle place torches! ---")
- end
- local function tryRefuel()
- if turtle.getFuelLevel() == 0 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- local function tryDig()
- while turtle.detect() == true do
- if turtle.dig() == false then
- return false
- end
- sleep(0.5)
- end
- end
- local function tryDigUp()
- while turtle.detectUp() == true do
- if turtle.digUp() == false then
- return false
- end
- sleep(0.5)
- end
- end
- local function tryDigDown()
- while turtle.detectDown() == true do
- if turtle.digDown() == false then
- return false
- end
- sleep(0.5)
- end
- end
- local function tryForward()
- if tryDig() == false then
- return false
- end
- tryRefuel()
- turtle.forward()
- end
- local function tryDown()
- if tryDigDown() == false then
- return false
- end
- tryRefuel()
- turtle.down()
- end
- local count = 0
- local torchSpacing = 3
- while true do
- count = count + 1
- if tryForward() == false then
- print("Can't dig that, aborting.")
- return
- end
- if tryDigUp() == false then
- print("Can't dig that, aborting.")
- return
- end
- if count % torchSpacing == 0 then
- if side == "right" then
- turtle.turnRight()
- tryDig()
- turtle.select(2)
- turtle.place()
- turtle.turnLeft()
- elseif side == "left" then
- turtle.turnLeft()
- tryDig()
- turtle.select(2)
- turtle.place()
- turtle.turnRight()
- end
- end
- if tryDown() == false then
- print("Can't dig that, aborting.")
- return
- end
- if tryDigDown() == false then
- print("Can't dig that, aborting.")
- return
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment