View difference between Paste ID: UH67gNRs and Suv4b39a
SHOW: | | - or go back to the newest paste.
1
local args={...}
2
local function gForward()
3
  while not turtle.forward() do
4
    turtle.dig()
5
  end
6
end
7
8
local function gUp()
9
  
10
  --print("GoingUp!")
11
  while not turtle.up() do
12
    turtle.digUp()
13
  end
14
end
15
16
local function digRow(length)
17
  for i=2,length do
18
    gForward()
19
  end
20
end
21
22
local function dig2Row(length)
23
  turtle.digUp()
24
  for i=2,length do
25
    gForward()
26
    turtle.digUp()
27
  end
28
end
29
30
local function placeChest()
31
  turtle.select(1)
32
  print("Placing the goods!")
33
  while not turtle.place() do
34
	turtle.dig()
35
  end
36
  for i=2,16 do
37
    turtle.select(i)
38-
   	turtle.drop()
38+
   	while not turtle.getItemCount(i) == 0 do
39
      turtle.drop()
40
    end
41
  end
42
  turtle.select(1)
43
  print("I'll take this chest with me.")
44
  turtle.dig()
45
  
46
end
47
  
48
49
local function digPlane(length,height)
50
  local remainingHeight = height
51
  local firstPass = true
52
  while remainingHeight > 0 do
53
    if not firstPass then
54
      gUp()
55
    else firstPass = false
56
    end
57
    if remainingHeight > 1 then
58
      dig2Row(length)
59
      gUp()
60
      remainingHeight = remainingHeight - 2
61
    else
62
      digRow(length)
63
      remainingHeight = remainingHeight - 1
64
    end
65
    turtle.turnLeft()
66
    turtle.turnLeft()
67
  end
68
  for i = 2,height do
69
    turtle.down()
70
  end
71
  if ((remainingHeight + 1) /2 ) % 2 == 1 then
72
    digRow(length)
73
	turtle.turnLeft()
74
	turtle.turnLeft()
75
  end
76
  placeChest()
77
end
78
79
local glength = tonumber(args[1])
80
local gheight = tonumber(args[2])
81
local gwidth = tonumber(args[3])
82
print("Okay, let's start!")
83
print("I hope there is an ender chest in my first inventory slot...")
84
for j = 1, gwidth do
85
  print("Starting Plane "..j)
86
  digPlane(glength,gheight)
87
  if not (j == gwidth) then
88
    turtle.turnLeft()
89
    gForward()
90
    turtle.turnRight()
91
  end
92
end