Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --declaring variables
- turtdir = 0
- glowy = 0
- glowx = 0
- print "This will mine a predefined pattern of blocks. Use after vertshaft or stairshaft."
- print "All values are positive integers."
- print "Fuel in slot 16, torches in slot 15."
- print "How wide is this mine?(x) !MUST BE AN ODD NUMBER!"
- x = io.read()
- x = tonumber(x)
- print "How far forward? (y)"
- y = io.read()
- y = tonumber(y)
- y = y-1
- print "How high? (z)"
- z = io.read()
- z = tonumber(z)
- z = z-1
- print "Press any key to run."
- os.pullEvent("char")
- -- origins
- sxo = x/2
- sxo = math.ceil(sxo)
- syo = y/2
- syo = math.ceil(syo)
- -- sxo and syo is used to find the turtle's start point. It is crucial that x be odd for this to work right.
- xo = 0
- yo = 0
- zo = 0
- setup = sxo/2
- setup = math.ceil(setup)
- -- declaring functions
- function checkFuel()
- if turtle.getFuelLevel() <= z*2+2 then
- turtle.select(16)
- turtle.refuel(1)
- end
- end
- function moveForward()
- checkFuel()
- repeat
- turtle.dig()
- until turtle.forward()
- end
- function mineUp()
- if zo == 0 then
- for i = 1,z do
- checkFuel()
- repeat
- turtle.digUp()
- until turtle.up()
- zo = zo+1
- end
- end
- end
- function mineDown()
- if zo ~= 0 then
- repeat
- checkFuel()
- repeat
- turtle.digDown()
- until turtle.down()
- zo = zo-1
- until zo == 0
- end
- end
- function checka()
- if turtle.getItemCount(14) >= 1 then
- turtle.turnLeft()
- for i = 1,yo do
- moveForward()
- checkFuel()
- end
- for i = 1,14 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1,yo do
- moveForward()
- checkFuel()
- end
- turtle.turnLeft()
- turtle.select(1)
- end
- end
- function checkb()
- if turtle.getItemCount(14) >= 1 then
- turtle.turnRight()
- for i = 1,yo do
- moveForward()
- checkFuel()
- end
- for i = 1,14 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i = 1,yo do
- moveForward()
- checkFuel()
- end
- turtle.turnRight()
- turtle.select(1)
- end
- end
- function torch()
- if glowx > 6 or glowx < 0 then
- glowx = 0
- end
- if glowy == 5 and glowx == 6 then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(15)
- turtle.place()
- turtle.turnRight()
- turtle.turnRight()
- glowx = glowx-glowx
- end
- end
- -- setting up to align
- turtle.turnLeft()
- for i = 1,setup do
- mineUp()
- moveForward()
- mineDown()
- moveForward()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- mineUp()
- mineDown()
- for i = 1,setup do
- moveForward()
- end
- for i = 1,setup do
- moveForward()
- mineUp()
- moveForward()
- mineDown()
- end
- -- and finally, on line 147, we have reached the main loop.
- for i = 1,syo do
- turtdir = 1
- checkb()
- turtle.turnLeft()
- moveForward()
- yo = yo+1
- if glowy == 6 then
- glowy = glowy-glowy
- end
- glowy = glowy+1
- turtle.turnLeft()
- for a = 1,sxo-1 do
- mineUp()
- moveForward()
- glowx = glowx+1
- xo = xo+1
- mineDown()
- moveForward()
- xo = xo+1
- glowx = glowx+1
- torch()
- end
- turtdir = 2
- checka()
- turtle.turnRight()
- mineUp()
- mineDown()
- moveForward()
- yo = yo+1
- if glowy == 6 then
- glowy = glowy-glowy
- end
- glowy = glowy+1
- turtle.turnRight()
- for b = 1,sxo-1 do
- mineUp()
- moveForward()
- xo = xo-1
- glowx = glowx-1
- mineDown()
- moveForward()
- xo = xo-1
- glowx = glowx-1
- torch()
- end
- mineUp()
- mineDown()
- end
- if turtdir == 1 then
- turtle.turnLeft()
- for i = 1,yo do
- moveForward()
- checkFuel()
- end
- for i = 1,16 do
- turtle.select(i)
- turtle.drop()
- end
- end
- if turtdir == 2 then
- turtle.turnRight()
- for i = 1,yo do
- moveForward()
- checkFuel()
- end
- for i = 1,16 do
- turtle.select(i)
- turtle.drop()
- end
- end
Add Comment
Please, Sign In to add comment