Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables
- local torchslot = 14
- local fuelslot = 16
- local woodslot = 13
- local chestslot =15
- local torch = 0
- local chest = 0
- local targs = { ... }
- steps = tonumber(targs[1])
- steps = steps or 1
- local fuelneeded = 0
- local torchesneeded = 0
- local chestneeded = 0
- local torchesgot = turtle.getItemCount(torchslot)
- local chestgot = turtle.getItemCount(torchslot)
- local fuellevel = 0
- -- Functions
- function digBlock()
- repeat
- turtle.dig()
- sleep(0.5)
- until not turtle.detect() == true
- end
- fuellevel = turtle.getFuelLevel()
- torchesgot = turtle.getItemCount(torchslot)
- chestgot = turtle.getItemCount(torchslot)
- -- Math
- fuelneeded = steps*5
- fuelneeded = fuelneeded+steps
- if steps > 40 then
- torchesneeded = steps/10
- chestneeded = steps/30
- else
- torchesneeded = 0
- chestneeded = 0
- end
- -- Welcome messages
- print(" ****************************")
- print(" * MineBot By BlackApple *")
- print(" ****************************")
- print(" *-= Distance to mine: ", steps)
- print(" *-= Fuel needed: ", fuelneeded)
- print(" *-= Fuel level: ", fuellevel)
- print(" *-= Torches needed: ", torchesneeded)
- print(" *-= Torch level: ", torchesgot)
- print(" *-= Chest needed: ", chestneeded)
- print(" *-= Torches Level: ", chestgot)
- print(" ****************************")
- -- Resource Acquiring
- if fuellevel < fuelneeded then
- print(" !! insert fuel in slot ", fuelslot)
- repeat
- sleep(0.5)
- turtle.select(fuelslot)
- turtle.refuel()
- fuellevel = turtle.getFuelLevel()
- until fuellevel > fuelneeded
- end
- if chestgot < chestneeded then
- print(" !! insert chests in slot ", chestslot)
- repeat
- sleep(0.5)
- turtle.select(chestslot)
- chestgot= turtle.getItemCount(chestslot)
- until chestgot >= chestneeded
- end
- if torchesgot < torchesneeded then
- print(" !! insert torches in slot ", torchslot)
- repeat
- sleep(0.5)
- turtle.select(torchslot)
- torchesgot = turtle.getItemCount(torchslot)
- until torchesgot >= torchesneeded
- end
- print("Resources acquired. Beginning mining...")
- stopdigging = 0
- -- Begin Digging
- for i = 1, steps do
- digBlock()
- turtle.forward()
- turtle.select(1)
- turtle.placeDown()
- repeat
- turtle.digUp()
- sleep(0.3)
- until turtle.up() == true
- repeat
- turtle.digUp()
- sleep(0.3)
- until turtle.up() == true
- turtle.turnLeft()
- turtle.dig()
- turtle.turnRight()
- turtle.turnRight()
- turtle.dig()
- turtle.down()
- turtle.dig()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.dig()
- turtle.down()
- digBlock()
- turtle.turnRight()
- turtle.turnRight()
- digBlock()
- turtle.turnLeft()
- torch = torch + 1
- if torch == 10 then
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(torchslot)
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.select(woodslot)
- torch = 1
- end
- chest = chest + 1
- if chest == 30 then
- turtle.turnLeft()
- turtle.select(chestslot)
- turtle.place()
- for q=1,12 do turtle.select(q) turtle.drop() end
- turtle.turnRight()
- turtle.select(woodslot)
- chest = 1
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.up()
- for i = 1, steps do
- turtle.forward()
- end
- turtle.down()
- turtle.turnLeft()
- turtle.turnLeft()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement