Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Dig a S shaped mine to the left or right based on input
- -- Checks for whether all slots are full, dumps everything in ender chest in slot 1.
- -- Places torches reasonably when they are placed in slot 16.
- function turnAround()
- for i=1,2 do
- turtle.turnLeft()
- end
- end
- function smartForward()
- --Dig a 2 high, 1 wide tunnel; gravel and sand friendly.
- while not turtle.forward() do
- turtle.dig()
- end
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.5)
- end
- end
- function snakeRight()
- -- Make a right turn in the snake.
- turtle.turnRight()
- for i=1,3 do
- smartForward()
- end
- torchPlace()
- turtle.turnRight()
- end
- function snakeLeft()
- -- Make a left turn in the snake.
- turtle.turnLeft()
- for i=1,3 do
- smartForward()
- end
- torchPlace()
- turtle.turnLeft()
- end
- function enderDump()
- --Dump contents of slots 2 through 15 in an ender chest.
- turnAround()
- turtle.select(1)
- turtle.place()
- for i=2,15 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(1)
- turtle.dig()
- turnAround()
- end
- function torchPlace()
- while turtle.getItemCount(16) == 0 do
- print("Waiting for more torches!")
- sleep(2)
- end
- turtle.select(16)
- turtle.turnRight()
- sleep(0.25)
- turtle.placeUp()
- turtle.turnLeft()
- turtle.select(1)
- end
- function isFull()
- if turtle.getItemCount(15) < 64 then
- return false
- end
- return true
- end
- local args = {...}
- if table.getn(args) < 1 then
- print("Usage: snakemine numBranch branchLength direction")
- print("numBranch is the number of loops to make.")
- print("branchLength is the length of the side branch")
- print("direction is left or right")
- print("Make sure torches are in slot 16!")
- print("Make sure Enderchest is in slot 1!")
- return
- end
- local numBranch = tonumber(args[1])
- local branchLength = tonumber(args[2])
- local direction = args[3]
- if direction == "left" then
- print("left-handed!")
- elseif direction == "right" then
- print("right-handed!")
- else
- print("Direction must be left or right!")
- return
- end
- local sincetorch = 0
- for a=1,numBranch do
- for b=1,branchLength do
- smartForward()
- sincetorch = sincetorch + 1
- if sincetorch == 10 then
- torchPlace()
- sincetorch = 0
- end
- if isFull() then
- enderDump()
- end
- end
- if direction == "left" then
- snakeRight()
- else
- snakeLeft()
- end
- for b=1,branchLength do
- smartForward()
- sincetorch = sincetorch + 1
- if sincetorch == 10 then
- torchPlace()
- sincetorch = 0
- end
- if isFull() then
- enderDump()
- end
- end
- if direction == "left" then
- snakeLeft()
- else
- snakeRight()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement