50% chance for sandstone pyramids in v6
[minetest_pyramids/tsm_pyramids.git] / room.lua
blob1a7ffd035e642d5a5840a393d6f5504cd52dc843
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 -- square
147 style = "yrepeat",
148 layout = {
149 " "," "," "," "," "," "," "," "," ",
150 " ","S","S","S","^","S","S","S"," ",
151 " ","S","S","S","S","S","S","S"," ",
152 " ","S","S","S","S","S","S","S"," ",
153 " ","S","S","S","S","S","S",">"," ",
154 " ","S","S","S","S","S","S","S"," ",
155 " ","S","S","S","S","S","S","S"," ",
156 " ","S","S","S","v","S","S","S"," ",
157 " "," "," "," "," "," "," "," "," ",
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, column_style)
566 local out = "default:"
567 if iy < 4 and (str == "<" or str == ">" or str == "^" or str == "v") then str = " " end
568 if column_style == 1 or column_style == 2 then
569 if iy == 0 and str == "s" then out = "tsm_pyramids:" str = deco[1] end
570 if iy == 3 and str == "s" then out = "tsm_pyramids:" str = deco[2] end
571 elseif column_style == 3 then
572 if iy == 0 and str == "s" then out = "tsm_pyramids:" str = deco[1] end
573 if iy == 2 and str == "s" then out = "tsm_pyramids:" str = deco[2] end
574 elseif column_style == 4 then
575 if iy == 2 and str == "s" then out = "tsm_pyramids:" str = deco[1] end
577 if str == " " then out = "" end
578 return out..code_table[str]
581 local function replace2(str, iy, code_table)
582 local out = "default:"
583 if iy == 0 and str == "~" then out = "tsm_pyramids:" str = "t"
584 elseif iy < 3 and str == "~" then str = " " end
586 if str == " " then out = "" end
587 return out..code_table[str]
590 function tsm_pyramids.make_room(pos, stype, room_id)
591 local code_table = code_sandstone
592 if stype == "desert" then
593 code_table = code_desert
595 -- Select random deco block
596 local deco_ids = {"1", "2", "3"}
597 local deco = {}
598 for i=1, 2 do
599 local r = math.random(1, #deco_ids)
600 table.insert(deco, deco_ids[r])
601 table.remove(deco_ids, r)
603 local hole = {x=pos.x+7,y=pos.y+5, z=pos.z+7}
604 if room_id == nil then
605 room_id = math.random(1, #room_types)
607 local room
608 if room_id < 1 or room_id > #room_types then
609 return false, S("Incorrect room type ID: @1", room_id)
611 local room = room_types[room_id]
612 local chests = {}
613 local column_style = math.random(0,4)
614 if room.style == "yrepeat" then
615 for iy=0,4,1 do
616 for ix=0,8,1 do
617 for iz=0,8,1 do
618 local n_str = room.layout[tonumber(ix*9+iz+1)]
619 local p2 = 0
620 if n_str == "<" then
621 p2 = 0
622 elseif n_str == ">" then
623 p2 = 2
624 elseif n_str == "^" then
625 p2 = 1
626 elseif n_str == "v" then
627 p2 = 3
629 local cpos = {x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}
630 local nn = replace(n_str, iy, code_table, deco, column_style)
631 minetest.set_node(cpos, {name=nn, param2=p2})
632 if nn == "default:chest" then
633 table.insert(chests, cpos)
638 else
639 minetest.log("error", "Invalid pyramid room style! room type ID="..r)
641 local sanded = room.flood_sand ~= false and math.random(1,8) == 1
642 if #chests > 0 then
643 -- Make at least 8 attempts to fill chests
644 local filled = 0
645 while filled < 8 do
646 for c=1, #chests do
647 tsm_pyramids.fill_chest(chests[c], stype, sanded)
648 filled = filled + 1
652 if room.traps then
653 tsm_pyramids.make_traps(pos, stype)
655 if sanded then
656 tsm_pyramids.flood_sand(pos, stype)
658 return true, nil, sanded
661 local shuffle_traps = function(chance)
662 layout_traps = table.copy(layout_traps_template)
663 for a=1, #layout_traps do
664 if layout_traps[a] == "?" then
665 if math.random(1,100) <= chance then
666 layout_traps[a] = "~"
667 else
668 layout_traps[a] = "S"
674 function tsm_pyramids.make_traps(pos, stype)
675 local code_table = code_sandstone
676 if stype == "desert" then
677 code_table = code_desert
679 shuffle_traps(math.random(10,100))
680 local hole = {x=pos.x+7,y=pos.y, z=pos.z+7}
681 for iy=0,4,1 do
682 for ix=0,8,1 do
683 for iz=0,8,1 do
684 local n_str = layout_traps[tonumber(ix*9+iz+1)]
685 local p2 = 0
686 minetest.set_node({x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}, {name=replace2(n_str, iy, code_table), param2=p2})
692 function tsm_pyramids.flood_sand(pos, stype)
693 local set_to_sand = {}
694 local nn = "default:sand"
695 if stype == "desert" then
696 nn = "default:desert_sand"
698 local hole = {x=pos.x+7,y=pos.y+1, z=pos.z+7}
699 local maxh = math.random(1,4)
700 local chance = math.random(1,7)
701 for ix=0,8,1 do
702 for iz=0,8,1 do
703 if math.random(1,chance) == 1 then
704 local h = math.random(1,maxh)
705 for iy=0,h,1 do
706 local p = {x=hole.x+ix,y=hole.y+iy,z=hole.z+iz}
707 if minetest.get_node(p).name == "air" then
708 table.insert(set_to_sand, p)
714 minetest.bulk_set_node(set_to_sand, {name=nn})