View difference between Paste ID: c9MuqRhB and n5jujFA1
SHOW: | | - or go back to the newest paste.
1
os.loadAPI("userInput.lua")
2
os.loadAPI("buildSupport.lua")
3
os.loadAPI("predictSupport.lua")
4
5
-- type dictates what part of the building is being made. type == 1 gets the cost of the floor and support pillars
6
-- type == 2 gets the cost of the walls, and type 3 gets the ceiling
7
-- CONCRETE ON LEFT, GLASS ON RIGHT
8
9
function blockCost(length, width, height, type)
10
	if type == 1 then
11
		return (width * length) + (height * 4)
12
	end
13
	if type == 2 then
14
		return (2 * (height * (width - 2))) + (2 * (height * (length - 2)))
15
	end
16
	if type == 3 then
17
		return (width * length)
18
	end
19
end
20-
function returnDownCeiling(length, width, height, floors)
20+
21
function countItemInInventory(itemName)
22
    local totalCount = 0
23
    
24
    -- Iterate over all slots in the turtle's inventory
25-
		turtle.forward()
25+
    for slot = 1, 16 do
26
        local itemDetail = turtle.getItemDetail(slot)
27
        
28
        -- If there's an item in the slot and it matches the specified item name, add to the total count
29-
		turtle.forward()
29+
        if itemDetail and itemDetail.name == itemName then
30
            totalCount = totalCount + itemDetail.count
31
        end
32
    end
33
    
34
    return totalCount
35
end
36-
	turtle.down()
36+
37
function returnDown(height, floors, blockname, blockname2)
38
	turtle.back()
39
	height = height + 1
40
	for i = 1, floors do
41-
function returnDown(height, floors)
41+
42
			turtle.down()
43
		end
44
	end
45
46
	turtle.turnLeft()
47
	concretecount = countItemInInventory(blockname)
48
	concreteneeded = 276 - concretecount
49
	concretemod = concreteneeded % 64
50
	
51
	for i = 1, math.floor(concreteneeded/64) do
52
		turtle.suck(64)
53
	end
54
	turtle.suck(concretemod)
55
	if countItemInInventory(blockname) < 276 then
56
		print("OUT OF CONCRETE")
57
		os.exit(1)
58
	end
59
60
	turtle.turnLeft()
61
	turtle.turnLeft()
62
	glasscount = countItemInInventory(blockname2)
63
	glassneeded = 280 - glasscount
64
	glassmod = glassneeded % 64
65
66
	for i = 1, math.floor(glassneeded/64) do
67
		turtle.suck(64)
68
	end
69
	turtle.suck(glassmod)
70
	if countItemInInventory(blockname2) < 280 then
71
		print("OUT OF GLASS")
72
		os.exit(1)
73-
choice = -1
73+
74-
choice2 = 2
74+
75-
choice3 = -1
75+
76
	for i = 1, floors do
77
		for j = 1, height do
78
			turtle.up()
79-
floors = 0
79+
80-
length = 0
80+
81-
width = 0
81+
	turtle.forward()
82-
height = 0
82+
83
84-
preset = tonumber(userInput.getUserInput("Preset? (Yes = 0, No = 1) "))
84+
85-
if preset == 0 then
85+
86-
	length = 16
86+
87-
	width = 16
87+
88-
	height = 5
88+
89-
	floors = 1
89+
90-
	choice = 2
90+
91-
	choice2 = 1
91+
92-
	choice3 = 1
92+
93
	end
94
	for i = 1, floors do
95-
while length == 0 do
95+
96-
	length = tonumber(userInput.getUserInput("Length: "))
96+
97
		end
98-
while width == 0 do
98+
99-
	width = tonumber(userInput.getUserInput("Width: "))
99+
100
	return tcost
101-
while height == 0 do
101+
102-
	height = tonumber(userInput.getUserInput("Height: "))
102+
103
blockname = "minecraft:black_concrete"
104
blockname2 = "minecraft:black_stained_glass_pane"
105-
while floors <= 0 do
105+
106-
	floors = tonumber(userInput.getUserInput("How Many Floors to Make?"))
106+
choice = 2
107
choice2 = 1
108
choice3 = 1
109-
while choice < 0 or choice > 2 do
109+
110-
	print("How Many Block Variants to Use?")
110+
111-
	choice = tonumber(userInput.getUserInput("Type 0 (for any available), 1, or 2"))
111+
112-
	if choice == 1 then
112+
floors = 1
113-
		while choice2 < 0 or choice2 > 1 do
113+
length = 16
114-
			print("Would you Like the Preset?")
114+
width = 16
115-
			choice2 = tonumber(userInput.getUserInput("Type 0 for Yes, 1 for No"))
115+
height = 5
116
117-
		if choice2 == 1 then
117+
floors = tonumber(userInput.getUserInput("How Many Floors to Make?"))
118-
			blockname = userInput.getUserInput("Please Input Block ID: ")
118+
119
for i = 1, floors do
120
	bcost = bcost + blockCost(length, width, height, 1)
121
	if choice == 2 then
122-
		while choice2 ~= 0 and choice2 ~= 1 do
122+
123-
			print("Would you Like the Preset?")
123+
124-
			choice2 = tonumber(userInput.getUserInput("Type 0 for Yes, 1 for No"))
124+
125
	end
126-
		if choice2 == 1 then
126+
127-
			blockname = userInput.getUserInput("Please Input Block #1's ID: ")
127+
128-
			blockname2 = userInput.getUserInput("Please Input Block #2's ID: ")
128+
129
	bcost = bcost + blockCost(length, width, height, 3)
130
	predictSupport.predictFloor(length, width)
131
end
132
fcost = fcost + predictSupport.getCost()
133-
while choice3 ~= 0 and choice3 ~= 1 do
133+
134-
	print("Build Ceiling?")
134+
135-
	choice3 = tonumber(userInput.getUserInput("Type 0 for Yes, 1 for No"))
135+
136
	choice2 = tonumber(userInput.getUserInput("Type 0 for Yes, 1 for No"))
137
end
138
139
if choice2 == 0 then
140
	fcost = fcost + predictReturnDown(length, width, height, floors)
141
end
142
143
while turtle.getFuelLevel() < fcost do
144
	print("Turtle Fuel Level Too Low for Build!")
145
	print("Fuel Needed" .. fcost)
146
	print("Current Fuel" .. turtle.getFuelLevel())
147
	print("Please Input Fuel")
148
	userInput.getUserInput("Press Enter to Continue")
149
	os.loadAPI("turtleRefuel.lua")
150
end
151
152
for j = 1, floors do
153-
if not preset then
153+
154-
	choice2 = 3
154+
155
		print("False 1")
156
		buildSupport.fullBuild(length, width, height)
157
	elseif choice == 1 and blockname ~= nil then
158
		print("False 2")
159
		buildSupport.fullBuildBlock(length, width, height, blockname)
160
	elseif choice == 2 and blockname ~= nil and blockname2 ~= nil then
161
		print("true")
162
		buildSupport.fullBuildBlocks(length, width, height, blockname, blockname2)
163
	end
164
	returnDown(height, j, blockname, blockname2)
165
end
166
returnDown(height, floors)
167
168