View difference between Paste ID: vkkAzdL0 and qKxfmwb0
SHOW: | | - or go back to the newest paste.
1
tArgs = {...}
2
3
local currentLevel = 0
4
local build = false
5
local currentSlot = 1
6-
local length = 1
6+
local size = 1
7-
local width = 1
7+
8
function isEmpty(slot)
9
  if turtle.getItemCount(slot) > 0 then
10-
  if turtle.getCount(slot) > 0 then
10+
11
  else
12
    return true
13
  end
14
end
15
16
function nextSlot()
17
  currentSlot = currentSlot + 1
18
  turtle.select(currentSlot)
19
end
20
21
function buildColumn()
22
  while turtle.detectDown() == false do
23-
	while turtle.detectDown() == false do
23+
	turtle.down()
24-
		turtle.down()
24+
	currentLevel = currentLevel + 1
25-
		currentLevel = currentLevel + 1
25+
26
27
  if turtle.detectDown() == true then
28-
	  if turtle.detectDown() == true then
28+
	for i = 1, currentLevel do
29-
		for i = 1, currentLevel do
29+
	  if isEmpty(currentSlot) == false then
30-
		  if isEmpty(currentSlot) == false
30+
		turtle.up()
31-
			turtle.up()
31+
		turtle.placeDown()
32-
			turtle.placeDown()
32+
	  else
33-
		  else
33+
		nextSlot()
34-
			nextSlot()
34+
		i = i - 1
35-
			i = i - 1
35+
36-
		  end
36+
37-
		end
37+
38
  currentLevel = 0
39
end
40
41
function buildTwoByTwo()
42
   buildColumn()
43
   turtle.forward()
44
   buildColumn()
45-
  if tArgs[2] == nil then
45+
   turtle.turnLeft()
46
   turtle.forward()
47
   buildColumn()
48
   turtle.turnLeft()
49-
    print("column length width")
49+
   turtle.forward()
50-
    build = false
50+
   buildColumn()
51
   turtle.turnLeft()
52-
    print("Building a "..tArgs[1].."x"..tArgs[2].." column")
52+
   turtle.forward()
53
   print("DONE")
54
end
55
56
function buildThreeByThree()
57
  buildColumn()
58
  turtle.forward()
59
  buildColumn()
60-
  if length > 1 then
60+
  turtle.forward()
61-
    for i = 1, length do
61+
62-
	  if width > 1 then
62+
  turtle.turnLeft()
63-
	    turtle.turnLeft()
63+
  turtle.forward()
64-
		for i = 1, width do
64+
  turtle.buildColumn()
65-
		  turtle.forward()
65+
  turtle.turnLeft()
66-
		  buildColumn()
66+
  turtle.forward()
67-
		  currentLevel = 0
67+
68-
		  for i = 1, width do
68+
  turtle.forward()
69-
		    turtle.back()
69+
70-
		  end
70+
  turtle.turnRight()
71-
		end
71+
  turtle.forward()
72-
		turtle.turnRight()
72+
73
  turtle.turnRight()
74-
	  turtle.forward()
74+
  turtle.forward()
75-
	  buildColumn()
75+
76-
	  currentLevel = 0
76+
  turtle.forward()
77
  buildColumn()
78-
	for i = 1, length do
78+
  turtle.turnRight()
79-
	  turtle.back()
79+
  turtle.turnRight()
80
  turtle.forward()
81
  turtle.forward()
82
  turtle.forward()  
83
end
84
85
function buildFourByFour()
86
  --
87
end
88
89
if tArgs[1] == nil then
90
  print("Building a 1 x 1 column")
91
  build = true
92
else
93
  if tArgs[2] == "2" or tArgs[2] == "3" or tArgs[2] == "4" then
94
    build = true
95
	size = tonumber(tArgs[1])
96
  else
97
    print("Invalid Usage.")
98
    print("Usage:")
99
    print("column")
100
    print("column size")
101
	print(" ")
102
	print("Valid column sizes: (2) = 2 x 2, (3) = 3 x 3, (4) = 4 x 4")
103
  end
104
end
105
106
if build == true then
107
  if size == 1 then
108
    buildColumn()
109
	print("DONE")
110
  elseif size == 2 then
111
    buildTwoByTwo()
112
  elseif size == 3 then
113
    buildThreeByThree()
114
  elseif size == 4 then
115
    buildFourByFour()
116
  end
117
end