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 | ||
8 | function blockCost(length, width, height, type) | |
9 | if type == 1 then | |
10 | return (width * length) + (height * 4) | |
11 | end | |
12 | if type == 2 then | |
13 | return (2 * (height * (width - 2))) + (2 * (height * (length - 2))) | |
14 | end | |
15 | if type == 3 then | |
16 | return (width * length) | |
17 | end | |
18 | end | |
19 | ||
20 | - | function returnDownCeiling(length, width, height, floors) |
20 | + | function countItemInInventory(itemName) |
21 | local totalCount = 0 | |
22 | ||
23 | -- Iterate over all slots in the turtle's inventory | |
24 | for slot = 1, 16 do | |
25 | - | turtle.forward() |
25 | + | local itemDetail = turtle.getItemDetail(slot) |
26 | ||
27 | -- If there's an item in the slot and it matches the specified item name, add to the total count | |
28 | if itemDetail and itemDetail.name == itemName then | |
29 | - | turtle.forward() |
29 | + | totalCount = totalCount + itemDetail.count |
30 | end | |
31 | end | |
32 | ||
33 | return totalCount | |
34 | end | |
35 | ||
36 | - | turtle.down() |
36 | + | function returnDown(height, floors, blockname, blockname2) |
37 | turtle.back() | |
38 | height = height + 1 | |
39 | for i = 1, floors do | |
40 | for j = 1, height do | |
41 | - | function returnDown(height, floors) |
41 | + | |
42 | end | |
43 | end | |
44 | ||
45 | turtle.turnLeft() | |
46 | concretecount = countItemInInventory(blockname) | |
47 | concreteneeded = 276 - concretecount | |
48 | concretemod = concreteneeded % 64 | |
49 | ||
50 | for i = 1, math.floor(concreteneeded/64) do | |
51 | turtle.suck(64) | |
52 | end | |
53 | turtle.suck(concretemod) | |
54 | if countItemInInventory(blockname) < 276 then | |
55 | print("OUT OF CONCRETE") | |
56 | os.exit(1) | |
57 | end | |
58 | ||
59 | turtle.turnLeft() | |
60 | turtle.turnLeft() | |
61 | glasscount = countItemInInventory(blockname2) | |
62 | glassneeded = 280 - glasscount | |
63 | glassmod = glassneeded % 64 | |
64 | ||
65 | for i = 1, math.floor(glassneeded/64) do | |
66 | turtle.suck(64) | |
67 | end | |
68 | turtle.suck(glassmod) | |
69 | if countItemInInventory(blockname2) < 280 then | |
70 | print("OUT OF GLASS") | |
71 | os.exit(1) | |
72 | end | |
73 | - | choice = -1 |
73 | + | |
74 | - | choice2 = 2 |
74 | + | |
75 | - | choice3 = -1 |
75 | + | |
76 | for j = 1, height do | |
77 | turtle.up() | |
78 | end | |
79 | - | floors = 0 |
79 | + | |
80 | - | length = 0 |
80 | + | turtle.forward() |
81 | - | width = 0 |
81 | + | |
82 | - | height = 0 |
82 | + | |
83 | function predictReturnDown(length, width, height, floors) | |
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 | for i = 1, floors do | |
94 | for j = 1, height 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 | end | |
101 | - | while height == 0 do |
101 | + | |
102 | - | height = tonumber(userInput.getUserInput("Height: ")) |
102 | + | |
103 | blockname2 = "minecraft:black_stained_glass_pane" | |
104 | ||
105 | - | while floors <= 0 do |
105 | + | choice = 2 |
106 | - | floors = tonumber(userInput.getUserInput("How Many Floors to Make?")) |
106 | + | choice2 = 1 |
107 | choice3 = 1 | |
108 | bcost = 0 | |
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 | + | floors = 1 |
112 | - | if choice == 1 then |
112 | + | length = 16 |
113 | - | while choice2 < 0 or choice2 > 1 do |
113 | + | width = 16 |
114 | - | print("Would you Like the Preset?") |
114 | + | height = 5 |
115 | - | choice2 = tonumber(userInput.getUserInput("Type 0 for Yes, 1 for No")) |
115 | + | |
116 | floors = tonumber(userInput.getUserInput("How Many Floors to Make?")) | |
117 | - | if choice2 == 1 then |
117 | + | |
118 | - | blockname = userInput.getUserInput("Please Input Block ID: ") |
118 | + | |
119 | bcost = bcost + blockCost(length, width, height, 1) | |
120 | if choice == 2 then | |
121 | bcost2 = bcost2 + blockCost(length, width, height, 2) | |
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 | predictSupport.predictFullBuild(length, width, height) | |
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 | predictSupport.predictFloor(length, width) | |
130 | end | |
131 | fcost = fcost + predictSupport.getCost() | |
132 | ||
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 | end | |
137 | ||
138 | if choice2 == 0 then | |
139 | fcost = fcost + predictReturnDown(length, width, height, floors) | |
140 | end | |
141 | ||
142 | while turtle.getFuelLevel() < fcost do | |
143 | print("Turtle Fuel Level Too Low for Build!") | |
144 | print("Fuel Needed" .. fcost) | |
145 | print("Current Fuel" .. turtle.getFuelLevel()) | |
146 | print("Please Input Fuel") | |
147 | userInput.getUserInput("Press Enter to Continue") | |
148 | os.loadAPI("turtleRefuel.lua") | |
149 | end | |
150 | ||
151 | for j = 1, floors do | |
152 | print(choice) | |
153 | - | if not preset then |
153 | + | |
154 | - | choice2 = 3 |
154 | + | |
155 | buildSupport.fullBuild(length, width, height) | |
156 | elseif choice == 1 and blockname ~= nil then | |
157 | print("False 2") | |
158 | buildSupport.fullBuildBlock(length, width, height, blockname) | |
159 | elseif choice == 2 and blockname ~= nil and blockname2 ~= nil then | |
160 | print("true") | |
161 | buildSupport.fullBuildBlocks(length, width, height, blockname, blockname2) | |
162 | end | |
163 | returnDown(height, j, blockname, blockname2) | |
164 | end | |
165 | returnDown(height, floors) | |
166 | ||
167 |