Flood every 8th pyramid with sand
[minetest_pyramids/tsm_pyramids.git] / room.lua
blobb0e53295303a14202ba4e443a51c4e346c6a660f
1 local S = minetest.get_translator("tsm_pyramids")
3 -- ROOM LAYOUTS
5 local room_types = {
6 -- Pillar room
8 style = "yrepeat",
9 layout = {
10 " "," "," "," "," "," "," "," "," ",
11 " ","^"," ","^"," ","^"," ","^"," ",
12 " ","s"," ","s"," ","s"," ","s"," ",
13 " "," "," "," "," "," "," "," "," ",
14 " "," "," "," "," "," "," "," "," ",
15 " "," "," "," "," "," "," "," "," ",
16 " ","s"," ","s"," ","s"," ","s"," ",
17 " ","v"," ","v"," ","v"," ","v"," ",
18 " "," "," "," "," "," "," "," "," "
20 traps = true,
22 -- Hieroglyph walls
24 style = "yrepeat",
25 layout = {
26 "s","s","s","s","s","s","s","s","s",
27 "s"," "," "," "," "," "," "," ","s",
28 "s"," "," "," "," "," "," "," ","s",
29 "s"," "," "," "," "," "," "," ","s",
30 " "," "," "," ","<"," "," "," ","s",
31 "s"," "," "," "," "," "," "," ","s",
32 "s"," "," "," "," "," "," "," ","s",
33 "s"," "," "," "," "," "," "," ","s",
34 "s","s","s","s","s","s","s","s","s"
37 -- 4 large pillars
39 style = "yrepeat",
40 layout = {
41 " "," "," "," ","v"," "," "," "," ",
42 " ","s","s"," "," "," ","s","s"," ",
43 " ","s","s"," "," "," ","s","s"," ",
44 " "," "," "," "," "," "," "," "," ",
45 " "," "," "," "," "," "," "," ","<",
46 " "," "," "," "," "," "," "," "," ",
47 " ","s","s"," "," "," ","s","s"," ",
48 " ","s","s"," "," "," ","s","s"," ",
49 " "," "," "," ","^"," "," "," "," "
52 -- hidden room
54 style = "yrepeat",
55 layout = {
56 " "," "," "," "," "," "," "," "," ",
57 " "," "," "," "," "," "," "," "," ",
58 " "," ","s","S","s","S","s"," "," ",
59 " "," ","S"," "," "," ","S"," "," ",
60 " "," ","s"," ",">"," ","s"," ","<",
61 " "," ","S"," "," "," ","S"," "," ",
62 " "," ","s","S","s","S","s"," "," ",
63 " "," "," "," "," "," "," "," "," ",
64 " "," "," "," "," "," "," "," "," "
67 -- spiral 1
69 style = "yrepeat",
70 layout = {
71 " "," "," "," "," "," "," "," "," ",
72 " ","S","S","S","S","S","S","S"," ",
73 " ","S"," "," "," "," "," ","S"," ",
74 " ","S"," ","s","s","s"," ","S"," ",
75 " ","S"," ","s","v","s"," ","S"," ",
76 "S","S"," ","s"," ","s"," ","S"," ",
77 "S","S"," ","s"," "," "," ","S"," ",
78 "v","S"," ","S","S","S","S","S"," ",
79 " ","S"," "," "," "," "," "," "," "
82 -- spiral 2
84 style = "yrepeat",
85 layout = {
86 " "," "," "," "," "," "," "," "," ",
87 " ","S","S","S","S","S","S","S"," ",
88 " "," "," ","s"," "," "," ","S"," ",
89 "S","S"," ","s"," ","s"," ","S"," ",
90 " ","S"," ","s","^","s"," ","S"," ",
91 " ","S"," ","s","s","s"," ","S"," ",
92 " ","S"," "," "," "," "," ","S"," ",
93 " ","S","S","S","S","S","S","S"," ",
94 " "," "," "," "," "," "," "," "," "
97 -- pillar mania
99 style = "yrepeat",
100 layout = {
101 " "," ","v"," ","v"," ","v"," ","v",
102 " ","s"," ","s"," ","s"," ","s"," ",
103 " "," "," "," "," "," "," "," "," ",
104 " ","s"," ","s"," ","s"," ","s"," ",
105 " "," "," "," "," "," "," "," "," ",
106 " ","s"," ","s"," ","s"," ","s"," ",
107 " "," "," "," "," "," "," "," "," ",
108 " ","s"," ","s"," ","s"," ","s"," ",
109 " "," ","^"," ","^"," ","^"," ","^",
111 --traps = true,
113 -- plusses
115 style = "yrepeat",
116 layout = {
117 "s"," "," "," "," "," "," "," ","s",
118 " "," ","s",">"," ","<","s"," "," ",
119 " ","s","s","s"," ","s","s","s"," ",
120 " "," ","s"," "," "," ","s"," "," ",
121 " "," "," "," ","<"," "," "," "," ",
122 " "," ","s"," "," "," ","s"," "," ",
123 " ","s","s","s"," ","s","s","s"," ",
124 " "," ","s",">"," ","<","s"," "," ",
125 "s"," "," "," "," "," "," "," ","s",
127 --traps = true,
129 -- diamond
131 style = "yrepeat",
132 layout = {
133 ">","s","s","s","s","s","s","s","s",
134 "s","s","s"," "," "," ","s","s","s",
135 "s","s"," "," "," "," "," ","s","s",
136 "s"," "," "," "," "," "," "," ","s",
137 " "," "," "," "," "," "," ","<","s",
138 "s"," "," "," "," "," "," "," ","s",
139 "s","s"," "," "," "," "," ","s","s",
140 "s","s","s"," "," "," ","s","s","s",
141 ">","s","s","s","s","s","s","s","s",
143 --traps = true,
145 -- hallway
147 style = "yrepeat",
148 layout = {
149 "S"," "," "," "," ","S","S","S"," ",
150 "S","^","^","S"," ","S","S",">"," ",
151 "S","S","S","S"," ","S","S",">"," ",
152 "S","S","S","S"," ","S","S","S"," ",
153 " "," "," "," "," "," "," "," "," ",
154 " ","S","S","S"," ","S","S","S","S",
155 " ","<","S","S"," ","S","S","S","S",
156 " ","<","S","S"," ","S","v","v","S",
157 " ","S","S","S"," "," "," "," "," ",
160 -- hallway 2
162 style = "yrepeat",
163 layout = {
164 "S","S","S","S",">"," "," "," "," ",
165 "S","S","S","S","S","^","S","S"," ",
166 "S","S","S","S","S","S","S","S"," ",
167 "S","S","S","S","S","S","S","S"," ",
168 " "," "," "," "," "," "," "," "," ",
169 "S","S","S","S","S","S","S","S"," ",
170 "S","S","S","S","S","S","S","S"," ",
171 "S","S","S","S","S","v","S","S"," ",
172 "S","S","S","S",">"," "," "," "," ",
175 -- hallway 3
177 style = "yrepeat",
178 layout = {
179 "S","S","S","S","S"," "," "," "," ",
180 "S","S","S","S","s",">"," "," "," ",
181 "S","s","S","s","S","s","S"," "," ",
182 " "," "," "," "," "," "," "," "," ",
183 " "," "," "," "," "," "," "," "," ",
184 " "," "," "," "," "," "," "," "," ",
185 "S","s","S","s","S","s","S"," "," ",
186 "S","S","S","S","s",">"," "," "," ",
187 "S","S","S","S","S"," "," "," "," ",
190 -- hallway 4
192 style = "yrepeat",
193 layout = {
194 "S","S","S","S","S","v","S","S","S",
195 "S","S","S","S","S","S","S","S","S",
196 "s","S","s","S","s","S","s","S","s",
197 " "," "," "," "," "," "," "," "," ",
198 " "," "," "," "," "," "," "," ","<",
199 " "," "," "," "," "," "," "," "," ",
200 "s","S","s","S","s","S","s","S","s",
201 "S","S","S","S","S","S","S","S","S",
202 "S","S","S","S","S","^","S","S","S",
205 -- tiny
207 style = "yrepeat",
208 layout = {
209 "S","S","S","S","S","S","S","S","v",
210 "S","S","S","S","S","S","S","S"," ",
211 "S","S","S","S","S","S","S","S"," ",
212 "S","S","S"," "," "," ","S","S"," ",
213 " "," "," "," ","<"," ","S","S"," ",
214 "S","S","S"," "," "," ","S","S"," ",
215 "S","S","S","S","S","S","S","S"," ",
216 "S","S","S","S","S","S","S","S"," ",
217 "S","S","S","S","S","S","S","S","^",
220 -- small
222 style = "yrepeat",
223 layout = {
224 "S","S","S","S","S","S","S","S","S",
225 "S","S","S","S","S","S","S","S","S",
226 "S","S"," ","v"," ","v"," ","S","S",
227 "S","S",">"," "," "," ","<","S"," ",
228 " "," "," "," ","s"," "," ","S"," ",
229 "S","S",">"," "," "," ","<","S"," ",
230 "S","S"," ","^"," ","^"," ","S","S",
231 "S","S","S","S","S","S","S","S","S",
232 "S","S","S","S","S","S","S","S","S",
235 -- small 2
237 style = "yrepeat",
238 layout = {
239 " "," "," "," "," "," "," "," "," ",
240 " ","S","S","S","S","S","S","S"," ",
241 " ","S"," "," ","v"," "," ","S"," ",
242 "S","S"," "," "," "," "," ","S"," ",
243 " "," "," "," "," "," ","<","S"," ",
244 "S","S"," "," "," "," "," ","S"," ",
245 " ","S"," "," ","^"," "," ","S"," ",
246 " ","S","S","S","S","S","S","S"," ",
247 " "," "," "," "," "," "," "," "," ",
250 -- big pillar
252 style = "yrepeat",
253 layout = {
254 " "," "," "," "," "," "," "," "," ",
255 " "," "," "," "," "," "," "," "," ",
256 " "," "," "," ","^"," "," "," "," ",
257 " "," "," ","s","s","s"," "," "," ",
258 " "," ","<","s","S","s",">"," "," ",
259 " "," "," ","s","s","s"," "," "," ",
260 " "," "," "," ","v"," "," "," "," ",
261 " "," "," "," "," "," "," "," "," ",
262 " "," "," "," "," "," "," "," "," ",
264 --traps = true,
266 -- pacman
268 style = "yrepeat",
269 layout = {
270 " "," "," "," "," "," "," "," "," ",
271 " "," "," "," "," "," "," "," "," ",
272 " "," "," ","s","s","s"," "," "," ",
273 " "," ","s","s","v","s","s"," "," ",
274 " "," ","s",">"," "," "," "," "," ",
275 " "," ","s","s","^","s","s"," "," ",
276 " "," "," ","s","s","s"," "," "," ",
277 " "," "," "," "," "," "," "," "," ",
278 " "," "," "," "," "," "," "," "," ",
281 -- the wall
283 style = "yrepeat",
284 layout = {
285 "S","S","S","S","S","S","S"," ","<",
286 "s","s","s","s","s","S","S"," ","s",
287 "s"," "," "," "," ","s","S"," ","<",
288 "s"," "," "," "," ","s","S"," ","s",
289 " "," "," "," ","<","s","S"," ","<",
290 "s"," "," "," "," ","s","S"," ","s",
291 "s"," "," "," "," ","s","S"," ","<",
292 "s","s","s","s","s","s","S"," ","s",
293 "S","S","S","S","S","S","S"," ","<",
296 -- split
298 style = "yrepeat",
299 layout = {
300 " "," "," "," "," "," "," "," "," ",
301 " "," "," "," "," "," "," "," "," ",
302 " "," "," "," "," "," "," "," "," ",
303 " "," "," ","^"," ","^"," "," "," ",
304 " "," "," ","s"," ","s"," "," "," ",
305 " "," "," ","v"," ","v"," "," "," ",
306 " "," "," "," "," "," "," "," "," ",
307 " "," "," "," "," "," "," "," "," ",
308 " "," "," "," "," "," "," "," "," ",
311 -- 4 small pillars
313 style = "yrepeat",
314 layout = {
315 " "," "," "," "," "," "," "," "," ",
316 " "," "," "," ","^"," "," "," "," ",
317 " "," "," "," ","s"," "," "," "," ",
318 " "," "," "," "," "," "," "," "," ",
319 " ","<","s"," "," "," ","s",">"," ",
320 " "," "," "," "," "," "," "," "," ",
321 " "," "," "," ","s"," "," "," "," ",
322 " "," "," "," ","v"," "," "," "," ",
323 " "," "," "," "," "," "," "," "," ",
326 -- 6 pillars
328 style = "yrepeat",
329 layout = {
330 " "," "," "," "," "," "," "," "," ",
331 " "," ","^"," ","^"," ","^"," "," ",
332 " "," ","s"," ","s"," ","s"," "," ",
333 " "," "," "," "," "," "," "," "," ",
334 " "," "," "," "," "," "," "," "," ",
335 " "," "," "," "," "," "," "," "," ",
336 " "," ","s"," ","s"," ","s"," "," ",
337 " "," ","v"," ","v"," ","v"," "," ",
338 " "," "," "," "," "," "," "," "," ",
340 traps = true,
342 -- stripes
344 style = "yrepeat",
345 layout = {
346 " ","S","v","S","v","S","v","S","v",
347 " ","S"," ","S"," ","S"," ","S"," ",
348 " ","s"," ","s"," ","s"," ","s"," ",
349 " "," "," "," "," "," "," "," "," ",
350 " "," "," "," "," "," "," "," "," ",
351 " "," "," "," "," "," "," "," "," ",
352 " ","s"," ","s"," ","s"," ","s"," ",
353 " ","S"," ","S"," ","S"," ","S"," ",
354 " ","S","^","S","^","S","^","S","^",
357 -- inside
359 style = "yrepeat",
360 layout = {
361 " "," "," "," "," "," "," "," "," ",
362 " ","s"," "," "," "," "," ","s"," ",
363 " "," "," "," "," "," "," "," "," ",
364 " "," "," ","s","S","s"," "," "," ",
365 " "," "," ","S",">"," "," "," "," ",
366 " "," "," ","s","S","s"," "," "," ",
367 " "," "," "," "," "," "," "," "," ",
368 " ","s"," "," "," "," "," ","s"," ",
369 " "," "," "," "," "," "," "," "," ",
372 -- 1 chest
374 style = "yrepeat",
375 layout = {
376 " "," "," "," "," "," "," "," "," ",
377 " "," "," "," "," "," "," "," "," ",
378 " "," "," "," "," "," "," "," "," ",
379 " "," "," "," "," "," "," "," "," ",
380 " "," "," "," ","<"," "," "," "," ",
381 " "," "," "," "," "," "," "," "," ",
382 " "," "," "," "," "," "," "," "," ",
383 " "," "," "," "," "," "," "," "," ",
384 " "," "," "," "," "," "," "," "," ",
387 -- 2 chests
389 style = "yrepeat",
390 layout = {
391 " "," "," "," "," "," "," "," "," ",
392 " "," "," "," "," "," "," "," ","<",
393 " "," "," "," "," "," "," "," "," ",
394 " "," "," "," "," "," "," "," "," ",
395 " "," "," "," "," "," "," "," "," ",
396 " "," "," "," "," "," "," "," "," ",
397 " "," "," "," "," "," "," "," "," ",
398 " "," "," "," "," "," "," "," ","<",
399 " "," "," "," "," "," "," "," "," ",
401 traps = true,
403 -- X
405 style = "yrepeat",
406 layout = {
407 "s"," "," "," "," "," "," "," ","s",
408 "s","s",">"," "," "," ","<","s","s",
409 " ","s","s"," "," "," ","s","s"," ",
410 " "," ","s","s"," ","s","s"," "," ",
411 " "," "," "," "," "," "," "," "," ",
412 " "," ","s","s"," ","s","s"," "," ",
413 " ","s","s"," "," "," ","s","s"," ",
414 "s","s",">"," "," "," ","<","s","s",
415 "s"," "," "," "," "," "," "," ","s",
418 -- split 2
420 style = "yrepeat",
421 layout = {
422 "S","S","S","S","S","S","S","S","S",
423 "S","S","S"," "," "," "," "," "," ",
424 "S","S","S"," "," "," "," "," "," ",
425 "S","S","S"," "," ","^","^","^","^",
426 " "," "," "," "," ","s","s","s","s",
427 "S","S","S"," "," ","v","v","v","v",
428 "S","S","S"," "," "," "," "," "," ",
429 "S","S","S"," "," "," "," "," "," ",
430 "S","S","S","S","S","S","S","S","S",
433 -- split 3
435 style = "yrepeat",
436 layout = {
437 " "," "," "," "," "," "," "," "," ",
438 " "," "," "," "," "," "," "," "," ",
439 " "," "," "," "," "," "," "," "," ",
440 " ","^"," ","^"," ","^"," ","^"," ",
441 " ","s"," ","s"," ","s"," ","s"," ",
442 " ","v"," ","v"," ","v"," ","v"," ",
443 " "," "," "," "," "," "," "," "," ",
444 " "," "," "," "," "," "," "," "," ",
445 " "," "," "," "," "," "," "," "," ",
448 -- diamond 2
450 style = "yrepeat",
451 layout = {
452 "S","S"," "," "," "," "," ","S","S",
453 "S"," "," "," ","s"," "," "," ","S",
454 " "," ","<","S","S","S",">"," "," ",
455 " "," ","S","S","S","S","S"," "," ",
456 " ","s","S","S","S","S","S","s"," ",
457 " "," ","S","S","S","S","S"," "," ",
458 " "," ","<","S","S","S",">"," "," ",
459 "S"," "," "," ","s"," "," "," ","S",
460 "S","S"," "," "," "," "," ","S","S",
463 -- ultra pillars
465 style = "yrepeat",
466 layout = {
467 " "," "," "," "," "," "," "," "," ",
468 " ","s","^","s"," ","s","^","s"," ",
469 " ","s","s","s"," ","s","s","s"," ",
470 " ","s","s","s"," ","s","s","s"," ",
471 " "," "," "," "," "," "," "," "," ",
472 " ","s","s","s"," ","s","s","s"," ",
473 " ","s","s","s"," ","s","s","s"," ",
474 " ","s","v","s"," ","s","v","s"," ",
475 " "," "," "," "," "," "," "," "," ",
478 -- vstripes
480 style = "yrepeat",
481 layout = {
482 "S"," "," "," "," "," "," "," "," ",
483 "S"," "," ","^"," "," ","^"," "," ",
484 "S"," "," ","s"," "," ","s"," "," ",
485 "S"," "," "," "," "," "," "," "," ",
486 " "," "," ","s"," "," ","s"," "," ",
487 "S"," "," "," "," "," "," "," "," ",
488 "S"," "," ","s"," "," ","s"," "," ",
489 "S"," "," ","v"," "," ","v"," "," ",
490 "S"," "," "," "," "," "," "," "," ",
493 -- sides
495 style = "yrepeat",
496 layout = {
497 "s"," ","s"," ","s"," ","s"," ","s",
498 " "," ","v"," ","v"," ","v"," "," ",
499 "s"," "," "," "," "," "," "," ","s",
500 " "," "," "," "," "," "," "," "," ",
501 " "," "," "," "," "," "," "," ","s",
502 " "," "," "," "," "," "," "," "," ",
503 "s"," "," "," "," "," "," "," ","s",
504 " "," ","^"," ","^"," ","^"," "," ",
505 "s"," ","s"," ","s"," ","s"," ","s",
507 traps = true,
509 -- 9 pillars
511 style = "yrepeat",
512 layout = {
513 " "," "," "," "," "," "," "," "," ",
514 " "," ","^"," ","^"," ","^"," "," ",
515 " "," ","s"," ","s"," ","s"," "," ",
516 " "," "," "," "," "," "," "," "," ",
517 " "," ","s"," ","s"," ","s"," "," ",
518 " "," "," "," "," "," "," "," "," ",
519 " "," ","s"," ","s"," ","s"," "," ",
520 " "," ","v"," ","v"," ","v"," "," ",
521 " "," "," "," "," "," "," "," "," ",
523 --traps = true,
530 local layout_traps
531 local layout_traps_template = {
532 "S","S","S","S","S","S","S","S","S",
533 "?","S","?","S","?","S","?","S","S",
534 "?","S","?","S","?","S","?","S","S",
535 "?","?","?","?","?","?","?","?","S",
536 "?","?","?","?","?","?","?","?","S", -- << entrance on left side
537 "?","?","?","?","?","?","?","?","S",
538 "?","S","?","S","?","S","?","S","S",
539 "?","S","?","S","?","S","?","S","S",
540 "S","S","S","S","S","S","S","S","S"
543 local code_sandstone = {
544 [" "] = "air",
545 ["s"] = "sandstone",
546 ["S"] = "sandstonebrick",
547 ["1"] = "deco_stone1",
548 ["2"] = "deco_stone2",
549 ["3"] = "deco_stone3",
550 ["^"] = "chest",
551 ["<"] = "chest",
552 [">"] = "chest",
553 ["v"] = "chest",
554 ["~"] = "lava_source",
555 ["t"] = "trap",
557 local code_desert = table.copy(code_sandstone)
558 code_desert["s"] = "desert_sandstone"
559 code_desert["1"] = "deco_stone4"
560 code_desert["2"] = "deco_stone5"
561 code_desert["3"] = "deco_stone6"
562 code_desert["S"] = "desert_sandstone_brick"
563 code_desert["t"] = "desert_trap"
565 local function replace(str, iy, code_table, deco)
566 local out = "default:"
567 if iy < 4 and (str == "<" or str == ">" or str == "^" or str == "v") then str = " " end
568 if iy == 0 and str == "s" then out = "tsm_pyramids:" str = deco[1] end
569 if iy == 3 and str == "s" then out = "tsm_pyramids:" str = deco[2] end
570 if str == " " then out = "" end
571 return out..code_table[str]
574 local function replace2(str, iy, code_table)
575 local out = "default:"
576 if iy == 0 and str == "~" then out = "tsm_pyramids:" str = "t"
577 elseif iy < 3 and str == "~" then str = " " end
579 if str == " " then out = "" end
580 return out..code_table[str]
583 function tsm_pyramids.make_room(pos, stype, room_id)
584 local code_table = code_sandstone
585 if stype == "desert" then
586 code_table = code_desert
588 -- Select random deco block
589 local deco_ids = {"1", "2", "3"}
590 local deco = {}
591 for i=1, 2 do
592 local r = math.random(1, #deco_ids)
593 table.insert(deco, deco_ids[r])
594 table.remove(deco_ids, r)
596 local hole = {x=pos.x+7,y=pos.y+5, z=pos.z+7}
597 if room_id == nil then
598 room_id = math.random(1, #room_types)
600 local room
601 if room_id < 1 or room_id > #room_types then
602 return false, S("Incorrect room type ID: @1", room_id)
604 local room = room_types[room_id]
605 local chests = {}
606 if room.style == "yrepeat" then
607 for iy=0,4,1 do
608 for ix=0,8,1 do
609 for iz=0,8,1 do
610 local n_str = room.layout[tonumber(ix*9+iz+1)]
611 local p2 = 0
612 if n_str == "<" then
613 p2 = 0
614 elseif n_str == ">" then
615 p2 = 2
616 elseif n_str == "^" then
617 p2 = 1
618 elseif n_str == "v" then
619 p2 = 3
621 local cpos = {x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}
622 local nn = replace(n_str, iy, code_table, deco)
623 minetest.set_node(cpos, {name=nn, param2=p2})
624 if nn == "default:chest" then
625 table.insert(chests, cpos)
630 else
631 minetest.log("error", "Invalid pyramid room style! room type ID="..r)
633 if #chests > 0 then
634 -- Make at least 8 attempts to fill chests
635 local filled = 0
636 while filled < 8 do
637 for c=1, #chests do
638 tsm_pyramids.fill_chest(chests[c])
639 filled = filled + 1
643 if room.traps then
644 tsm_pyramids.make_traps(pos, stype)
646 local sanded = false
647 if room.flood_sand ~= false then
648 if math.random(1,8) == 1 then
649 tsm_pyramids.flood_sand(pos, stype)
650 sanded = true
653 return true, nil, sanded
656 local shuffle_traps = function(chance)
657 layout_traps = table.copy(layout_traps_template)
658 for a=1, #layout_traps do
659 if layout_traps[a] == "?" then
660 if math.random(1,100) <= chance then
661 layout_traps[a] = "~"
662 else
663 layout_traps[a] = "S"
669 function tsm_pyramids.make_traps(pos, stype)
670 local code_table = code_sandstone
671 if stype == "desert" then
672 code_table = code_desert
674 shuffle_traps(math.random(10,100))
675 local hole = {x=pos.x+7,y=pos.y, z=pos.z+7}
676 for iy=0,4,1 do
677 for ix=0,8,1 do
678 for iz=0,8,1 do
679 local n_str = layout_traps[tonumber(ix*9+iz+1)]
680 local p2 = 0
681 minetest.set_node({x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}, {name=replace2(n_str, iy, code_table), param2=p2})
687 function tsm_pyramids.flood_sand(pos, stype)
688 local nn = "default:sand"
689 if stype == "desert" then
690 nn = "default:desert_sand"
692 local hole = {x=pos.x+7,y=pos.y+1, z=pos.z+7}
693 local maxh = math.random(1,4)
694 local chance = math.random(1,7)
695 for ix=0,8,1 do
696 for iz=0,8,1 do
697 if math.random(1,chance) == 1 then
698 local h = math.random(1,maxh)
699 for iy=0,h,1 do
700 local p = {x=hole.x+ix,y=hole.y+iy,z=hole.z+iz}
701 if minetest.get_node(p).name == "air" then
702 minetest.set_node(p, {name=nn})