Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- MINER
- Made by HDGamer14
- Alpha had has bugs most likely :(
- --]]
- local rows,length,torchs,x,y,x1,y1,direction,direction1,miner
- function turn(dirc)
- if dirc == "left" then
- turtle.turnLeft()
- if direction == 3 then
- direction = 0
- else
- direction = direction + 1
- end
- else
- turtle.turnRight()
- if direction == 0 then
- direction = 3
- else
- direction = direction - 1
- end
- end
- end
- function goforward()
- if turtle.forward() == false then
- repeat
- turtle.dig()
- turtle.attack()
- sleep(0.5)
- until turtle.forward() == true
- end
- end
- function forward()
- checkfuel()
- if direction == 0 then
- goforward()
- x = x + 1
- elseif direction == 2 then
- goforward()
- x = x - 1
- elseif direction == 3 then
- goforward()
- y = y - 1
- else
- goforward()
- y = y + 1
- end
- end
- function checkfuel()
- if turtle.getFuelLevel() < 5 then
- print("Place fuel in slot 15")
- repeat
- sleep(1)
- until turtle.getItemCount(15) > 0
- turtle.select(15)
- turtle.refuel(turtle.getItemCount(15))
- print("Refueled, curent about of fuel : "..turtle.getFuelLevel())
- end
- end
- function gohome()
- x1 = x
- y1 = y
- direction1 = direction
- while direction ~= 3 do
- turn("right")
- end
- while y ~= 0 do
- forward()
- end
- turn("right")
- while x ~= 0 do
- forward()
- end
- end
- function goback()
- while direction ~= 0 do
- turn("right")
- end
- while x ~= x1 do
- forward()
- end
- turn("left")
- while y ~= y1 do
- forward()
- end
- while direction ~= direction1 do
- turn("right")
- end
- end
- function mine()
- turtle.digUp()
- turtle.dig()
- turtle.digDown()
- end
- function torch( )
- if torchs == true then
- if math.fmod(x,4) == 0 then
- if math.fmod(y,4) == 0 then
- turtle.select(16)
- turtle.placeDown()
- end
- end
- end
- end
- function row(lrow)
- for i=1,lrow do
- mine()
- torch()
- if turtle.getItemCount(12) > 0 then
- gohome()
- unload()
- goback()
- end
- forward()
- -- print("X : ".. x)
- -- print("Y : ".. y)
- -- print("direction : "..direction)
- -- print()
- end
- end
- function newrow()
- --forward()
- if (y == rows - 1) then
- -- print("Swag rows = y")
- if direction == 0 then
- turn("right")
- mine()
- else
- turn("left")
- mine()
- end
- else
- if direction == 0 then
- turn("left")
- mine()
- forward()
- turn("left")
- else
- turn("right")
- mine()
- forward()
- turn("right")
- end
- end
- end
- function unload()
- print ("Unloading items...")
- for n=1,15 do
- turtle.select(n)
- turtle.drop()
- end
- turtle.select(1)
- end
- function cycle()
- row(length - 1)
- newrow()
- end
- x = 0
- y = 0
- direction = 0
- -- Program start
- shell.run("clear")
- print("Place chest behind me!")
- print("How far you you like me to go?")
- length=read()
- print("How many rows would you like me to mine?")
- rows=read(number)
- -- if row == 1 then
- -- newRow = false
- -- end
- print("Would you like me to use torches? (yes/no)")
- torchs=read()
- if torchs == "yes" then
- print("Place torhes in slot 16")
- repeat
- sleep(1)
- until turtle.getItemCount(16) > 0
- torchs = true
- else
- torchs = false
- end
- miner = rows
- repeat
- cycle()
- miner = miner - 1
- until miner == 0
- gohome()
- unload()
- --print("X : ".. x)
- --print("Y : ".. y)
- --print("direction : "..direction)
- print("All done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement