Differences From
Artifact [3af63c8d88]:
1 1 local lib = starlit.mod.lib
2 2 local B = starlit.mod.building
3 -B.stage.link('starlit_building:stage_foundation', {
3 +
4 +local function fabFor(x)
5 + local def = ItemStack(x):get_definition()
6 + assert(def ~= nil, 'invalid item ID ' .. tostring(x))
7 + return (def._starlit and def._starlit.recover) or starlit.type.fab {}
8 +end
9 +
10 +B.stage.link('starlit_building:foundation', {
4 11 tex = {
5 12 'starlit-node-concrete.png';
6 13 };
7 14 begin = {
8 15 part = {
9 16 'starlit_building:concrete';
10 17 };
11 18 };
12 19 build = {
13 20 part = {
14 21 ['starlit_building:insulation'] = 'starlit_building:stage_foundation_insulation';
22 + ['starlit_building:concrete'] = 'starlit_building:step_concrete';
15 23 };
16 24 };
25 + recover = fabFor 'starlit_building:concrete';
17 26 box = {
18 27 type = 'fixed';
19 28 fixed = {
20 29 -.5, -.5, -.5;
21 30 .5, -.5 + (2/16), .5;
22 31 };
23 32 };
24 33 })
25 34
26 -B.stage.link('starlit_building:stage_foundation_insulation', {
35 +B.stage.link('starlit_building:step_concrete', {
27 36 tex = {
28 - 'starlit-node-insulation-top.png';
29 37 'starlit-node-concrete.png';
30 - 'starlit-node-floor-panel-side.png';
31 38 };
32 39 build = {
33 40 part = {
34 - ['starlit_building:insulation'] = 'starlit_building:stage_foundation_insulation_x2';
35 - ['starlit_building:cable_electric'] = 'starlit_building:stage_foundation_insulation_conduit';
41 + ['starlit_building:concrete'] = 'starlit_building:pillar_concrete';
36 42 };
37 43 };
38 - box = {
39 - type = 'fixed';
40 - fixed = {
41 - -.5, -.5, -.5;
42 - .5, -.5 + (6/16), .5;
43 - };
44 - };
45 -})
46 -
47 -B.stage.link('starlit_building:stage_foundation_insulation_x2', {
48 - tex = {
49 - 'starlit-node-insulation-top.png';
50 - 'starlit-node-concrete.png';
51 - 'starlit-node-floor-panel-side.png';
52 - };
53 - build = {
54 - part = {
55 - ['starlit_building:panel'] = 'starlit_building:floor';
56 - };
57 - };
58 - box = {
59 - type = 'fixed';
60 - fixed = {
61 - -.5, -.5, -.5;
62 - .5, -.5 + (14/16), .5;
63 - };
64 - };
65 -})
66 -
67 -B.stage.link('starlit_building:stage_foundation_insulation_conduit', {
68 - tex = {
69 - 'starlit-node-insulation-cable-top.png';
70 - 'starlit-node-concrete.png';
71 - 'starlit-node-floor-panel-side-conduit.png';
72 - };
73 - groups = {
74 - conduit = 1;
75 - };
76 - build = {
77 - part = {
78 - ['starlit_building:insulation'] = 'starlit_building:stage_foundation_insulated_conduit';
79 - };
80 - };
44 + recover = fabFor 'starlit_building:concrete' * 2;
81 45 box = {
82 46 type = 'fixed';
83 47 fixed = {
84 48 -.5, -.5, -.5;
85 49 .5, -.5 + (8/16), .5;
86 50 };
87 51 };
88 52 })
89 53
90 -B.stage.link('starlit_building:stage_foundation_insulated_conduit', {
54 +B.stage.link('starlit_building:pillar_concrete', {
55 + tex = {
56 + 'starlit-node-concrete.png';
57 + };
58 + recover = fabFor 'starlit_building:concrete' * 3;
59 +})
60 +
61 +B.stage.link('starlit_building:stage_foundation_insulation', {
91 62 tex = {
92 63 'starlit-node-insulation-top.png';
93 64 'starlit-node-concrete.png';
94 - 'starlit-node-floor-panel-side-conduit.png';
65 + 'starlit-node-floor-panel-side.png';
95 66 };
67 + recover = fabFor 'starlit_building:concrete'
68 + + fabFor 'starlit_building:insulation';
96 69 build = {
97 70 part = {
98 - ['starlit_building:panel'] = 'starlit_building:conduit';
71 + ['starlit_building:panel'] = 'starlit_building:floor';
99 72 };
100 - };
101 - groups = {
102 - conduit = 1;
73 + tool = {
74 + object = {
75 + speed = 2;
76 + drop = 'starlit_building:insulation';
77 + swap = 'starlit_building:foundation';
78 + };
79 + };
103 80 };
104 81 box = {
105 82 type = 'fixed';
106 83 fixed = {
107 84 -.5, -.5, -.5;
108 - .5, -.5 + (14/16), .5;
85 + .5, -.5 + (12/16), .5;
109 86 };
110 87 };
111 88 })
112 89
113 -B.stage.link('starlit_building:conduit', {
114 - tex = {
115 - 'starlit-node-floor-panel-top.png';
116 - 'starlit-node-concrete.png';
117 - 'starlit-node-floor-panel-side-conduit.png';
118 - };
119 - groups = {
120 - conduit = 1;
121 - };
122 -})
90 +B.panelRun = lib.registry.mk 'starlit_building:panelRun'
91 +B.panelRun.foreach('starlit_building:runGen', {}, function(id, run)
92 + local F = string.format
93 + assert(run.name, 'missing name for panelrun')
94 + local name = run.name
95 + local buildPart = ItemStack(run.buildPart):get_name()
96 + local plugItem = ItemStack(run.plugItem):get_name()
97 + local floorStageRaw = id .. '_floor_open'
98 + local floorStage = id .. '_floor'
99 + local floorStagePlug = id .. '_floor_plug'
100 +
101 + local wallStageRaw = id .. '_wall_open'
102 + local wallStage = id .. '_wall'
103 + local wallStagePlug = id .. '_wall_plug'
104 +
105 + local texRun = run.run or F('starlit-node-%s-run.png', name)
106 + local texPlug = run.plug or F('starlit-node-%s-plug.png', name)
107 +
108 + local imgRun = lib.image(texRun)
109 + local imgPlug = lib.image(texPlug)
110 +
111 + local baseMat = fabFor(run.buildPart) + fabFor 'starlit_building:insulation'
112 + local floorMat = baseMat + fabFor 'starlit_building:concrete'
113 + local wallMat = baseMat + fabFor 'starlit_building:panel'
114 +
115 + ------------------
116 + -- floor stages --
117 + ------------------
118 + B.stage.link(floorStageRaw, {
119 + tex = {
120 + imgRun:blit(lib.image 'starlit-node-insulation-top.png'):render();
121 + 'starlit-node-concrete.png';
122 + imgPlug:blit(lib.image 'starlit-node-floor-panel-side.png'):render();
123 + };
124 + recover = floorMat;
125 + build = {
126 + part = {
127 + ['starlit_building:panel'] = floorStage;
128 + };
129 + tool = {
130 + object = {
131 + speed = 1;
132 + drop = run.buildPart;
133 + swap = floorStageRaw;
134 + };
135 + };
136 + };
137 + box = {
138 + type = 'fixed';
139 + fixed = {
140 + -.5, -.5, -.5;
141 + .5, -.5 + (12/16), .5;
142 + };
143 + };
144 + })
145 +
146 + local floorBasis = run.floorBasis or 'starlit_building:stage_foundation_insulation'
147 + B.pathLink(floorBasis, 'part', buildPart, floorStageRaw)
148 +
149 + mat = floorMat + fabFor 'starlit_building:panel';
150 + B.stage.link(floorStage, {
151 + tex = {
152 + 'starlit-node-floor-panel-top.png';
153 + 'starlit-node-concrete.png';
154 + imgPlug:blit(lib.image 'starlit-node-floor-panel-side.png'):render();
155 + };
156 + recover = floorMat + fabFor 'starlit_building:panel';
157 + build = {
158 + part = {
159 + [plugItem] = floorStagePlug;
160 + };
161 + tool = {
162 + unscrew = {
163 + speed = 1;
164 + drop = 'starlit_building:panel';
165 + swap = floorBasis;
166 + };
167 + };
168 + };
169 + groups = run.groups;
170 + })
171 +
172 + if run.plugGroups then
173 + B.stage.link(floorStagePlug, {
174 + tex = {
175 + imgPlug:blit(lib.image 'starlit-node-floor-panel-top.png'):render();
176 + 'starlit-node-concrete.png';
177 + imgPlug:blit(lib.image 'starlit-node-floor-panel-side.png'):render();
178 + };
179 + recover = floorMat + fabFor(run.plugItem);
180 + build = {
181 + tool = {
182 + unscrew = {
183 + speed = 1;
184 + drop = run.plugItem;
185 + swap = floorStage;
186 + };
187 + };
188 + };
189 + groups = run.plugGroups;
190 + })
191 + end
192 +
193 + -----------------
194 + -- wall stages --
195 + -----------------
196 + local imgPanel = lib.image 'starlit-node-insulated-panels.png'
197 + B.stage.link(wallStageRaw, {
198 + tex = {
199 + imgPlug:blit(imgPanel):render();
200 + imgPlug:blit(imgPanel):render();
201 +
202 + imgPlug:blit(imgPanel:transform 'R270'):render();
203 + imgPlug:blit(imgPanel:transform 'R90'):render();
204 +
205 + imgRun:blit(lib.image 'starlit-node-insulation-top.png'):render();
206 + 'starlit-node-floor-panel-top.png';
207 + };
208 + recover = wallMat;
209 + build = {
210 + part = {
211 + ['starlit_building:panel'] = wallStage;
212 + };
213 + };
214 + groups = run.groups;
215 + paramtype2 = '4dir';
216 + box = {
217 + type = 'fixed';
218 + fixed = {
219 + -.5, -.5, -.5;
220 + 0.5, 0.5, -.5 + (12/16);
221 + };
222 + };
223 + })
224 +
225 + local wallBasis = run.wallBasis or 'starlit_building:stage_wall_insulation'
226 + B.pathLink(wallBasis, 'part', buildPart, wallStageRaw)
227 +
228 + B.stage.link(wallStage, {
229 + tex = {
230 + imgPlug:blit(imgPanel):render();
231 + imgPlug:blit(imgPanel):render();
232 +
233 + imgPlug:blit(imgPanel:transform 'R270'):render();
234 + imgPlug:blit(imgPanel:transform 'R90'):render();
235 +
236 + 'starlit-node-floor-panel-top.png';
237 + 'starlit-node-floor-panel-top.png';
238 + };
239 + recover = wallMat + fabFor 'starlit_building:panel';
240 + build = {
241 + part = {
242 + [plugItem] = wallStagePlug;
243 + };
244 + };
245 + paramtype2 = '4dir';
246 + groups = run.groups;
247 + })
248 +
249 + if run.plugGroups then
250 + B.stage.link(wallStagePlug, {
251 + tex = {
252 + imgPlug:blit(imgPanel):render();
253 + imgPlug:blit(imgPanel):render();
254 +
255 + imgPlug:blit(imgPanel:transform 'R270'):render();
256 + imgPlug:blit(imgPanel:transform 'R90'):render();
257 +
258 + 'starlit-node-floor-panel-top.png';
259 + imgPlug:blit(lib.image 'starlit-node-floor-panel-top.png'):render();
260 + };
261 + recover = wallMat + fabFor(plugItem);
262 + build = {
263 + };
264 + paramtype2 = '4dir';
265 + groups = run.plugGroups;
266 + })
267 + end
268 +end)
269 +
123 270
124 271 B.stage.link('starlit_building:floor', {
125 272 tex = {
126 273 'starlit-node-floor-panel-top.png';
127 274 'starlit-node-concrete.png';
128 275 'starlit-node-floor-panel-side.png';
276 + };
277 + recover = fabFor 'starlit_building:concrete'
278 + + fabFor 'starlit_building:insulation'
279 + + fabFor 'starlit_building:panel';
280 + build = {
281 + tool = {
282 + unscrew = {
283 + speed = 2;
284 + drop = 'starlit_building:panel';
285 + swap = 'starlit_building:stage_foundation_insulation';
286 + };
287 + };
288 + };
289 +})
290 +
291 +B.stage.link('starlit_building:stage_wall_panel', {
292 + tex = {
293 + 'starlit-node-insulated-panels.png';
294 + 'starlit-node-insulated-panels.png';
295 + 'starlit-node-insulated-panels.png^[transformR270';
296 + 'starlit-node-insulated-panels.png^[transformR90';
297 + 'starlit-node-floor-panel-top.png';
298 + };
299 + recover = fabFor 'starlit_building:panel';
300 + begin = {
301 + part = {'starlit_building:panel'};
302 + };
303 + build = {
304 + part = {
305 + ['starlit_building:insulation'] = 'starlit_building:stage_wall_insulation';
306 + };
307 + };
308 + paramtype2 = '4dir';
309 + box = {
310 + type = 'fixed';
311 + fixed = {
312 + -.5, -.5, -.5;
313 + 0.5, 0.5, -.5 + (2/16);
314 + };
315 + };
316 +})
317 +
318 +B.stage.link('starlit_building:stage_wall_insulation', {
319 + tex = {
320 + 'starlit-node-insulated-panels.png';
321 + 'starlit-node-insulated-panels.png';
322 + 'starlit-node-insulated-panels.png^[transformR270';
323 + 'starlit-node-insulated-panels.png^[transformR90';
324 + 'starlit-node-insulation-top.png';
325 + 'starlit-node-floor-panel-top.png';
326 + };
327 + recover = fabFor 'starlit_building:panel'
328 + + fabFor 'starlit_building:insulation';
329 + build = {
330 + part = {
331 + ['starlit_building:panel'] = 'starlit_building:wall';
332 + };
333 + };
334 + paramtype2 = '4dir';
335 + box = {
336 + type = 'fixed';
337 + fixed = {
338 + -.5, -.5, -.5;
339 + 0.5, 0.5, -.5 + (12/16);
340 + };
341 + };
342 +})
343 +
344 +B.stage.link('starlit_building:wall', {
345 + tex = {
346 + 'starlit-node-insulated-panels.png';
347 + 'starlit-node-insulated-panels.png';
348 + 'starlit-node-insulated-panels.png^[transformR270';
349 + 'starlit-node-insulated-panels.png^[transformR90';
350 + 'starlit-node-floor-panel-top.png';
351 + 'starlit-node-floor-panel-top.png';
352 + };
353 + recover = (fabFor 'starlit_building:panel' * 2)
354 + + fabFor 'starlit_building:insulation';
355 + build = {
356 + };
357 + paramtype2 = '4dir';
358 +})
359 +
360 +
361 +B.panelRun.link('starlit_building:conduit_power', {
362 + name = 'cable';
363 + buildPart = 'starlit_building:cable_electric';
364 + plugItem = 'starlit_building:electrode';
365 + groups = {
366 + conduit_power = 1;
367 + conduit_data = 1;
368 + };
369 + plugGroups = {
370 + conduit_power = 2;
371 + conduit_data = 2;
372 + };
373 +})
374 +
375 +B.panelRun.link('starlit_building:conduit_fluid', {
376 + name = 'pipe';
377 + buildPart = 'starlit_building:pipe';
378 + plugItem = 'starlit_building:pipe';
379 + groups = {
380 + conduit_fluid = 1;
381 + };
382 + plugGroups = {
383 + conduit_fluid = 2;
129 384 };
130 385 })