Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables
- local tArgs = { ... }
- distance = tonumber(tArgs[1])
- distance = distance or 8
- branchl = tonumber(tArgs[2])
- branchl = branchl or 3
- loops = tonumber(tArgs[3])
- loops = loops or 2
- ladder = tonumber(tArgs[4])
- ladder = ladder or 0
- -- checks if ladder is in slot 2 if param is set
- function checkmaterials()
- if ladder == 1 then
- while turtle.getItemCount(2) <= 5*ladder do
- print("Please put " .. 5*loops.. " ladder in slot 2")
- sleep(5)
- end
- end
- end
- -- Functions --
- --Fuels the turtle and waits for fuel if nothing left
- function tFuel(amount)
- if turtle.getItemCount(1) > 1 then
- if turtle.getFuelLevel() < 3 then
- turtle.select(1)
- turtle.refuel(amount)
- end
- else
- while turtle.getItemCount(1) < 1 do
- print "Out of fuel!"
- print "put fuel in slot 1"
- sleep(5)
- end
- end
- end
- -- move forward make sure there is no gravel stopping the turtle fuelcheck implemented here
- local function moveForward()
- while turtle.detect() do
- turtle.dig()
- end
- moved = false
- while not(moved) do
- moved = turtle.forward()
- end
- tFuel(1)
- end
- -- same like forward
- function moveUp()
- turtle.digUp()
- moved = false
- while not(moved) do
- while turtle.detectUp() do
- turtle.digUp()
- end
- moved = turtle.up()
- end
- tFuel(1)
- end
- -- in case there is a mob or player better include notmoved
- local function moveDown()
- for i = 1,5 do
- turtle.digDown()
- moved = false
- while not(moved) do
- moved = turtle.down()
- end
- end
- tFuel(1)
- end
- -- just cause im lazy for typing :D/>/>/>
- local function digginUpnDown()
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.digDown()
- end
- -- digs out the branch on both sides
- local function digBranch()
- for b = 1,branchl do
- moveForward()
- digginUpnDown()
- end
- turtle.turnLeft()
- moveForward()
- turtle.turnLeft()
- digginUpnDown()
- for b = 1,branchl do
- moveForward()
- digginUpnDown()
- end
- moveForward()
- digginUpnDown()
- for b = 1,branchl do
- moveForward()
- digginUpnDown()
- end
- turtle.turnLeft()
- moveForward()
- turtle.turnLeft()
- digginUpnDown()
- for b = 1,branchl do
- moveForward()
- digginUpnDown()
- end
- moveForward()
- digginUpnDown()
- end
- -- dig the main Hall
- local function digHall()
- for h=0, distance do
- moveForward()
- digginUpnDown()
- if h%4 == 0 then
- turtle.turnRight()
- digBranch()
- turtle.turnLeft()
- end
- end
- turtle.turnLeft()
- moveForward()
- turtle.turnLeft()
- digginUpnDown()
- for h=0,distance do
- moveForward()
- digginUpnDown()
- end
- turtle.turnLeft()
- moveForward()
- turtle.turnLeft()
- digginUpnDown()
- end
- -- going up to starting point again
- local function goback()
- if ladder == 1 then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- for i =1, loops*5+1 do
- if ladder == 1 then
- turtle.select(2)
- turtle.dig()
- turtle.place()
- moveUp()
- else
- moveUp()
- end
- end
- end
- -- code excecution
- print("Work, work!")
- checkmaterials()
- for i=1,loops do
- tFuel(1)
- moveDown()
- digHall()
- end
- goback()
Advertisement
Add Comment
Please, Sign In to add comment