View difference between Paste ID: bvnEVJV5 and uLXefFg9
SHOW: | | - or go back to the newest paste.
1
local config = {}
2
config.itemFuel = 80
3
config.fuelSlot = 16
4
5
local data = {}
6
data.distance = 0
7
data.fuelBuff = 0
8
9
function reloadFuelBuff()
10
  data.fuelBuff = turtle.getItemCount()*config.itemFuel
11
end
12
13
function checkInv()
14
  return turtle.getItemCount(16) > 0
15-
    turtle.refuel()
15+
16
17
function checkFuel()
18
  if(turtle.getFuelLevel() < 10) then
19
    turtle.refuel(1)
20
	reloadFuelBuff()
21-
  if(!turtle.forward()) then
21+
22
  return turtle.getFuelLevel()+data.fuelBuff > data.distance+5 
23
end
24
25
function goForward(i)
26
  if(not turtle.forward()) then
27
    if(t>=5) then error("Immovable Object") end
28
    turtle.dig()
29
    goForward(i and i+1 or 1)
30
  end
31
end
32
33
function finish()
34
  turtle.turnLeft()
35
  turtle.turnLeft()
36-
function digLoop()
36+
37
    goForward()
38
  end
39
end
40
41
function digLoop()
42
	goForward()
43
	turtle.digDown()
44
	turtle.digUp()
45
end
46
47
function init()
48
	reloadFuelBuff()
49
	while checkFuel() and checkInv() do
50
		digLoop()
51
	end
52
	finish()
53
end
54
print("Ready? Put fuel in the active slot")
55
read()
56
init()