Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- full = false
- Fuel = true
- cposi = 0
- pposi = 0
- cposiB = 0
- pposiB = 0
- branch = false
- cposiB = 0
- function forward()
- moved = turtle.forward()
- while not(moved) do
- sleep(1)
- turtle.dig()
- moved=turtle.forward()
- end
- end
- function checkInv()
- if turtle.getItemCount(15) ~= 0 then
- full = true
- end
- end
- function checkFuel()
- CFuel = turtle.getFuelLevel()
- if not(branch) then
- if CFuel <= cposi then
- Fuel = false
- end
- if CFuel <= cposi + 5 then
- Fuel = false
- end
- else
- if CFuel <= cposi or CFuel <= 5+cposi or CFuel <= 42+cposi then
- Fuel =false
- end
- end
- end
- function checkifbranch()
- n=0
- while n < cposi do
- n=n+4
- end
- if n == cposi and not(n==0) then
- branch = true
- end
- end
- function gohome()
- while cposi ~= 0 do
- forward()
- cposi = cposi-1
- end
- end
- function gomine()
- while cposi ~= pposi do
- forward()
- cposi = cposi+1
- end
- end
- function home()
- turtle.turnLeft()
- turtle.turnLeft()
- gohome()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=2,15 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(1)
- full = false
- if turtle.getItemCount(16) > 64 then
- turtle.select(16)
- turtle.suckUp()
- turtle.select(2)
- turtle.dropUp()
- turtle.select(1)
- end
- while turtle.getFuelLevel() < 2*pposi do
- q=turtle.getItemCount(1)
- q= q -1
- turtle.select(2)
- turtle.refuel(q)
- turtle.select(1)
- print("refueling...")
- sleep(15)
- end
- Fuel = true
- gomine()
- end
- function ifhomeL()
- checkInv()
- if full then
- turtle.turnRight()
- turtle.turnRight()
- while cposiB ~= 0 do
- forward()
- cposiB = cposiB - 1
- end
- turtle.turnLeft()
- home()
- turtle.turnLeft()
- while cposiB ~= pposiB do
- forward()
- cposiB = cposiB + 1
- end
- end
- end
- function ifhomeR()
- checkInv()
- if full then
- turtle.turnRight()
- turtle.turnRight()
- while cposiB ~= 0 do
- forward()
- cposiB = cposiB - 1
- end
- turtle.turnRight()
- home()
- turtle.turnRight()
- while cposiB ~= pposiB do
- forward()
- cposiB = cposiB + 1
- end
- end
- end
- function gobranchLeft()
- pposiB = 0
- turtle.turnLeft()
- while cposiB ~= 21 do
- pposiB = pposiB + 1
- cposiB = cposiB + 1
- forward()
- ifhomeL()
- turtle.digUp()
- ifhomeL()
- turtle.digDown()
- ifhomeL()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- while cposiB ~= 0 do
- forward()
- if cposiB == 7 or cposiB== 14 or cposiB== 20 then
- turtle.select(16)
- turtle.placeDown()
- turtle.select(1)
- end
- cposiB = cposiB - 1
- end
- pposiB= 0
- turtle.turnLeft()
- end
- function gobranchRight()
- pposiB = 0
- turtle.turnRight()
- while cposiB ~= 21 do
- pposiB = pposiB + 1
- cposiB = cposiB + 1
- forward()
- ifhomeR()
- turtle.digUp()
- ifhomeR()
- turtle.digDown()
- ifhomeR()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- while cposiB ~= 0 do
- forward()
- if cposiB == 7 or cposiB== 14 or cposiB== 20 then
- turtle.select(16)
- turtle.placeDown()
- turtle.select(1)
- end
- cposiB = cposiB - 1
- end
- pposiB= 0
- turtle.turnRight()
- end
- function mineM()
- turtle.select(1)
- checkInv()
- checkifbranch()
- checkFuel()
- if full == true or Fuel==false then
- home()
- end
- if branch then
- gobranchLeft()
- checkFuel()
- checkInv()
- if not(Fuel) or full then
- home()
- end
- gobranchRight()
- branch=false
- t=0
- while t < cposi do
- t=t+8
- end
- if t == cposi and not(t==0) then
- turtle.select(16)
- turtle.placeDown()
- turtle.select(1)
- end
- checkFuel()
- checkInv()
- if not(Fuel) or full then
- home()
- end
- end
- forward()
- cposi= cposi+1
- pposi= pposi+1
- checkInv()
- if full then
- home()
- end
- turtle.digUp()
- checkInv()
- if full then
- home()
- end
- turtle.digDown()
- checkInv()
- if full then
- home()
- end
- turtle.turnLeft()
- forward()
- checkInv()
- if full then
- turtle.turnRight()
- turtle.turnRight()
- forward()
- turtle.turnLeft()
- home()
- turtle.turnLeft()
- forward()
- end
- turtle.digDown()
- checkInv()
- if full then
- turtle.turnRight()
- turtle.turnRight()
- forward()
- turtle.turnLeft()
- home()
- turtle.turnLeft()
- forward()
- end
- turtle.digUp()
- checkInv()
- if full then
- turtle.turnRight()
- turtle.turnRight()
- forward()
- turtle.turnLeft()
- home()
- turtle.turnLeft()
- forward()
- end
- turtle.turnRight()
- turtle.turnRight()
- forward()
- forward()
- if full then
- turtle.turnRight()
- turtle.turnRight()
- forward()
- turtle.turnRight()
- home()
- turtle.turnRight()
- forward()
- end
- turtle.digUp()
- checkInv()
- if full then
- turtle.turnRight()
- turtle.turnRight()
- forward()
- turtle.turnRight()
- home()
- turtle.turnRight()
- forward()
- end
- turtle.digDown()
- checkInv()
- if full then
- turtle.turnRight()
- turtle.turnRight()
- forward()
- turtle.turnRight()
- home()
- turtle.turnRight()
- forward()
- end
- turtle.turnRight()
- turtle.turnRight()
- forward()
- turtle.turnRight()
- end
- tArgs={...}
- q = tArgs[1]
- target= q*4
- while pposi~= target do
- mineM()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement