Update mummy doll properties for MT 5.0.0
[minetest_pyramids/tsm_pyramids.git] / room.lua
blobef28e1ab0612bd65275dade91edd7738c1daed88
1 local S = minetest.get_translator("tsm_pyramids")
3 -- ROOM LAYOUTS
5 local ROOM_WIDTH = 9
7 local room_types = {
8 -- Pillar room
10 style = "yrepeat",
11 layout = {
12 " "," "," "," "," "," "," "," "," ",
13 " ","^"," ","^"," ","^"," ","^"," ",
14 " ","s"," ","s"," ","s"," ","s"," ",
15 " "," "," "," "," "," "," "," "," ",
16 " "," "," "," "," "," "," "," "," ",
17 " "," "," "," "," "," "," "," "," ",
18 " ","s"," ","s"," ","s"," ","s"," ",
19 " ","v"," ","v"," ","v"," ","v"," ",
20 " "," "," "," "," "," "," "," "," "
22 traps = true,
24 -- Hieroglyph walls
26 style = "yrepeat",
27 layout = {
28 "s","s","s","s","s","s","s","s","s",
29 "s"," "," "," "," "," "," "," ","s",
30 "s"," "," "," "," "," "," "," ","s",
31 "s"," "," "," "," "," "," "," ","s",
32 " "," "," "," ","<"," "," "," ","s",
33 "s"," "," "," "," "," "," "," ","s",
34 "s"," "," "," "," "," "," "," ","s",
35 "s"," "," "," "," "," "," "," ","s",
36 "s","s","s","s","s","s","s","s","s"
39 -- 4 large pillars
41 style = "yrepeat",
42 layout = {
43 " "," "," "," ","v"," "," "," "," ",
44 " ","s","s"," "," "," ","s","s"," ",
45 " ","s","s"," "," "," ","s","s"," ",
46 " "," "," "," "," "," "," "," "," ",
47 " "," "," "," "," "," "," "," ","<",
48 " "," "," "," "," "," "," "," "," ",
49 " ","s","s"," "," "," ","s","s"," ",
50 " ","s","s"," "," "," ","s","s"," ",
51 " "," "," "," ","^"," "," "," "," "
54 -- hidden room
56 style = "yrepeat",
57 layout = {
58 " "," "," "," "," "," "," "," "," ",
59 " "," "," "," "," "," "," "," "," ",
60 " "," ","s","S","s","S","s"," "," ",
61 " "," ","S"," "," "," ","S"," "," ",
62 " "," ","s"," ",">"," ","s"," ","<",
63 " "," ","S"," "," "," ","S"," "," ",
64 " "," ","s","S","s","S","s"," "," ",
65 " "," "," "," "," "," "," "," "," ",
66 " "," "," "," "," "," "," "," "," "
69 -- spiral 1
71 style = "yrepeat",
72 layout = {
73 " "," "," "," "," "," "," "," "," ",
74 " ","S","S","S","S","S","S","S"," ",
75 " ","S"," "," "," "," "," ","S"," ",
76 " ","S"," ","s","s","s"," ","S"," ",
77 " ","S"," ","s","v","s"," ","S"," ",
78 "S","S"," ","s"," ","s"," ","S"," ",
79 "S","S"," ","s"," "," "," ","S"," ",
80 "v","S"," ","S","S","S","S","S"," ",
81 " ","S"," "," "," "," "," "," "," "
84 -- spiral 2
86 style = "yrepeat",
87 layout = {
88 " "," "," "," "," "," "," "," "," ",
89 " ","S","S","S","S","S","S","S"," ",
90 " "," "," ","s"," "," "," ","S"," ",
91 "S","S"," ","s"," ","s"," ","S"," ",
92 " ","S"," ","s","^","s"," ","S"," ",
93 " ","S"," ","s","s","s"," ","S"," ",
94 " ","S"," "," "," "," "," ","S"," ",
95 " ","S","S","S","S","S","S","S"," ",
96 " "," "," "," "," "," "," "," "," "
99 -- pillar mania
101 style = "yrepeat",
102 layout = {
103 " "," ","v"," ","v"," ","v"," ","v",
104 " ","s"," ","s"," ","s"," ","s"," ",
105 " "," "," "," "," "," "," "," "," ",
106 " ","s"," ","s"," ","s"," ","s"," ",
107 " "," "," "," "," "," "," "," "," ",
108 " ","s"," ","s"," ","s"," ","s"," ",
109 " "," "," "," "," "," "," "," "," ",
110 " ","s"," ","s"," ","s"," ","s"," ",
111 " "," ","^"," ","^"," ","^"," ","^",
113 --traps = true,
115 -- plusses
117 style = "yrepeat",
118 layout = {
119 "s"," "," "," "," "," "," "," ","s",
120 " "," ","s",">"," ","<","s"," "," ",
121 " ","s","s","s"," ","s","s","s"," ",
122 " "," ","s"," "," "," ","s"," "," ",
123 " "," "," "," ","<"," "," "," "," ",
124 " "," ","s"," "," "," ","s"," "," ",
125 " ","s","s","s"," ","s","s","s"," ",
126 " "," ","s",">"," ","<","s"," "," ",
127 "s"," "," "," "," "," "," "," ","s",
129 --traps = true,
131 -- diamond
133 style = "yrepeat",
134 layout = {
135 ">","s","s","s","s","s","s","s","s",
136 "s","s","s"," "," "," ","s","s","s",
137 "s","s"," "," "," "," "," ","s","s",
138 "s"," "," "," "," "," "," "," ","s",
139 " "," "," "," "," "," "," ","<","s",
140 "s"," "," "," "," "," "," "," ","s",
141 "s","s"," "," "," "," "," ","s","s",
142 "s","s","s"," "," "," ","s","s","s",
143 ">","s","s","s","s","s","s","s","s",
145 --traps = true,
147 -- square
149 style = "yrepeat",
150 layout = {
151 " "," "," "," "," "," "," "," "," ",
152 " ","S","S","S","^","S","S","S"," ",
153 " ","S","S","S","S","S","S","S"," ",
154 " ","S","S","S","S","S","S","S"," ",
155 " ","S","S","S","S","S","S",">"," ",
156 " ","S","S","S","S","S","S","S"," ",
157 " ","S","S","S","S","S","S","S"," ",
158 " ","S","S","S","v","S","S","S"," ",
159 " "," "," "," "," "," "," "," "," ",
162 -- hallway 2
164 style = "yrepeat",
165 layout = {
166 "S","S","S","S",">"," "," "," "," ",
167 "S","S","S","S","S","^","S","S"," ",
168 "S","S","S","S","S","S","S","S"," ",
169 "S","S","S","S","S","S","S","S"," ",
170 " "," "," "," "," "," "," "," "," ",
171 "S","S","S","S","S","S","S","S"," ",
172 "S","S","S","S","S","S","S","S"," ",
173 "S","S","S","S","S","v","S","S"," ",
174 "S","S","S","S",">"," "," "," "," ",
177 -- hallway 3
179 style = "yrepeat",
180 layout = {
181 "S","S","S","S","S"," "," "," "," ",
182 "S","S","S","S","s",">"," "," "," ",
183 "S","s","S","s","S","s","S"," "," ",
184 " "," "," "," "," "," "," "," "," ",
185 " "," "," "," "," "," "," "," "," ",
186 " "," "," "," "," "," "," "," "," ",
187 "S","s","S","s","S","s","S"," "," ",
188 "S","S","S","S","s",">"," "," "," ",
189 "S","S","S","S","S"," "," "," "," ",
192 -- hallway 4
194 style = "yrepeat",
195 layout = {
196 "S","S","S","S","S","v","S","S","S",
197 "S","S","S","S","S","S","S","S","S",
198 "s","S","s","S","s","S","s","S","s",
199 " "," "," "," "," "," "," "," "," ",
200 " "," "," "," "," "," "," "," ","<",
201 " "," "," "," "," "," "," "," "," ",
202 "s","S","s","S","s","S","s","S","s",
203 "S","S","S","S","S","S","S","S","S",
204 "S","S","S","S","S","^","S","S","S",
207 -- tiny
209 style = "yrepeat",
210 layout = {
211 "S","S","S","S","S","S","S","S","v",
212 "S","S","S","S","S","S","S","S"," ",
213 "S","S","S","S","S","S","S","S"," ",
214 "S","S","S"," "," "," ","S","S"," ",
215 " "," "," "," ","<"," ","S","S"," ",
216 "S","S","S"," "," "," ","S","S"," ",
217 "S","S","S","S","S","S","S","S"," ",
218 "S","S","S","S","S","S","S","S"," ",
219 "S","S","S","S","S","S","S","S","^",
222 -- small
224 style = "yrepeat",
225 layout = {
226 "S","S","S","S","S","S","S","S","S",
227 "S","S","S","S","S","S","S","S","S",
228 "S","S"," ","v"," ","v"," ","S","S",
229 "S","S",">"," "," "," ","<","S"," ",
230 " "," "," "," ","s"," "," ","S"," ",
231 "S","S",">"," "," "," ","<","S"," ",
232 "S","S"," ","^"," ","^"," ","S","S",
233 "S","S","S","S","S","S","S","S","S",
234 "S","S","S","S","S","S","S","S","S",
237 -- small 2
239 style = "yrepeat",
240 layout = {
241 " "," "," "," "," "," "," "," "," ",
242 " ","S","S","S","S","S","S","S"," ",
243 " ","S"," "," ","v"," "," ","S"," ",
244 "S","S"," "," "," "," "," ","S"," ",
245 " "," "," "," "," "," ","<","S"," ",
246 "S","S"," "," "," "," "," ","S"," ",
247 " ","S"," "," ","^"," "," ","S"," ",
248 " ","S","S","S","S","S","S","S"," ",
249 " "," "," "," "," "," "," "," "," ",
252 -- big pillar
254 style = "yrepeat",
255 layout = {
256 " "," "," "," "," "," "," "," "," ",
257 " "," "," "," "," "," "," "," "," ",
258 " "," "," "," ","^"," "," "," "," ",
259 " "," "," ","s","s","s"," "," "," ",
260 " "," ","<","s","S","s",">"," "," ",
261 " "," "," ","s","s","s"," "," "," ",
262 " "," "," "," ","v"," "," "," "," ",
263 " "," "," "," "," "," "," "," "," ",
264 " "," "," "," "," "," "," "," "," ",
266 --traps = true,
268 -- pacman
270 style = "yrepeat",
271 layout = {
272 " "," "," "," "," "," "," "," "," ",
273 " "," "," "," "," "," "," "," "," ",
274 " "," "," ","s","s","s"," "," "," ",
275 " "," ","s","s","v","s","s"," "," ",
276 " "," ","s",">"," "," "," "," "," ",
277 " "," ","s","s","^","s","s"," "," ",
278 " "," "," ","s","s","s"," "," "," ",
279 " "," "," "," "," "," "," "," "," ",
280 " "," "," "," "," "," "," "," "," ",
283 -- the wall
285 style = "yrepeat",
286 layout = {
287 "S","S","S","S","S","S","S"," ","<",
288 "s","s","s","s","s","S","S"," ","s",
289 "s"," "," "," "," ","s","S"," ","<",
290 "s"," "," "," "," ","s","S"," ","s",
291 " "," "," "," ","<","s","S"," ","<",
292 "s"," "," "," "," ","s","S"," ","s",
293 "s"," "," "," "," ","s","S"," ","<",
294 "s","s","s","s","s","s","S"," ","s",
295 "S","S","S","S","S","S","S"," ","<",
298 -- split
300 style = "yrepeat",
301 layout = {
302 " "," "," "," "," "," "," "," "," ",
303 " "," "," "," "," "," "," "," "," ",
304 " "," "," "," "," "," "," "," "," ",
305 " "," "," ","^"," ","^"," "," "," ",
306 " "," "," ","s"," ","s"," "," "," ",
307 " "," "," ","v"," ","v"," "," "," ",
308 " "," "," "," "," "," "," "," "," ",
309 " "," "," "," "," "," "," "," "," ",
310 " "," "," "," "," "," "," "," "," ",
313 -- 4 small pillars
315 style = "yrepeat",
316 layout = {
317 " "," "," "," "," "," "," "," "," ",
318 " "," "," "," ","^"," "," "," "," ",
319 " "," "," "," ","s"," "," "," "," ",
320 " "," "," "," "," "," "," "," "," ",
321 " ","<","s"," "," "," ","s",">"," ",
322 " "," "," "," "," "," "," "," "," ",
323 " "," "," "," ","s"," "," "," "," ",
324 " "," "," "," ","v"," "," "," "," ",
325 " "," "," "," "," "," "," "," "," ",
328 -- 6 pillars
330 style = "yrepeat",
331 layout = {
332 " "," "," "," "," "," "," "," "," ",
333 " "," ","^"," ","^"," ","^"," "," ",
334 " "," ","s"," ","s"," ","s"," "," ",
335 " "," "," "," "," "," "," "," "," ",
336 " "," "," "," "," "," "," "," "," ",
337 " "," "," "," "," "," "," "," "," ",
338 " "," ","s"," ","s"," ","s"," "," ",
339 " "," ","v"," ","v"," ","v"," "," ",
340 " "," "," "," "," "," "," "," "," ",
342 traps = true,
344 -- stripes
346 style = "yrepeat",
347 layout = {
348 " ","S","v","S","v","S","v","S","v",
349 " ","S"," ","S"," ","S"," ","S"," ",
350 " ","s"," ","s"," ","s"," ","s"," ",
351 " "," "," "," "," "," "," "," "," ",
352 " "," "," "," "," "," "," "," "," ",
353 " "," "," "," "," "," "," "," "," ",
354 " ","s"," ","s"," ","s"," ","s"," ",
355 " ","S"," ","S"," ","S"," ","S"," ",
356 " ","S","^","S","^","S","^","S","^",
359 -- inside
361 style = "yrepeat",
362 layout = {
363 " "," "," "," "," "," "," "," "," ",
364 " ","s"," "," "," "," "," ","s"," ",
365 " "," "," "," "," "," "," "," "," ",
366 " "," "," ","s","S","s"," "," "," ",
367 " "," "," ","S",">"," "," "," "," ",
368 " "," "," ","s","S","s"," "," "," ",
369 " "," "," "," "," "," "," "," "," ",
370 " ","s"," "," "," "," "," ","s"," ",
371 " "," "," "," "," "," "," "," "," ",
374 -- 1 chest
376 style = "yrepeat",
377 layout = {
378 " "," "," "," "," "," "," "," "," ",
379 " "," "," "," "," "," "," "," "," ",
380 " "," "," "," "," "," "," "," "," ",
381 " "," "," "," "," "," "," "," "," ",
382 " "," "," "," ","<"," "," "," "," ",
383 " "," "," "," "," "," "," "," "," ",
384 " "," "," "," "," "," "," "," "," ",
385 " "," "," "," "," "," "," "," "," ",
386 " "," "," "," "," "," "," "," "," ",
389 -- 2 chests
391 style = "yrepeat",
392 layout = {
393 " "," "," "," "," "," "," "," "," ",
394 " "," "," "," "," "," "," "," ","<",
395 " "," "," "," "," "," "," "," "," ",
396 " "," "," "," "," "," "," "," "," ",
397 " "," "," "," "," "," "," "," "," ",
398 " "," "," "," "," "," "," "," "," ",
399 " "," "," "," "," "," "," "," "," ",
400 " "," "," "," "," "," "," "," ","<",
401 " "," "," "," "," "," "," "," "," ",
403 traps = true,
405 -- X
407 style = "yrepeat",
408 layout = {
409 "s"," "," "," "," "," "," "," ","s",
410 "s","s",">"," "," "," ","<","s","s",
411 " ","s","s"," "," "," ","s","s"," ",
412 " "," ","s","s"," ","s","s"," "," ",
413 " "," "," "," "," "," "," "," "," ",
414 " "," ","s","s"," ","s","s"," "," ",
415 " ","s","s"," "," "," ","s","s"," ",
416 "s","s",">"," "," "," ","<","s","s",
417 "s"," "," "," "," "," "," "," ","s",
420 -- split 2
422 style = "yrepeat",
423 layout = {
424 "S","S","S","S","S","S","S","S","S",
425 "S","S","S"," "," "," "," "," "," ",
426 "S","S","S"," "," "," "," "," "," ",
427 "S","S","S"," "," ","^","^","^","^",
428 " "," "," "," "," ","s","s","s","s",
429 "S","S","S"," "," ","v","v","v","v",
430 "S","S","S"," "," "," "," "," "," ",
431 "S","S","S"," "," "," "," "," "," ",
432 "S","S","S","S","S","S","S","S","S",
435 -- split 3
437 style = "yrepeat",
438 layout = {
439 " "," "," "," "," "," "," "," "," ",
440 " "," "," "," "," "," "," "," "," ",
441 " "," "," "," "," "," "," "," "," ",
442 " ","^"," ","^"," ","^"," ","^"," ",
443 " ","s"," ","s"," ","s"," ","s"," ",
444 " ","v"," ","v"," ","v"," ","v"," ",
445 " "," "," "," "," "," "," "," "," ",
446 " "," "," "," "," "," "," "," "," ",
447 " "," "," "," "," "," "," "," "," ",
450 -- diamond 2
452 style = "yrepeat",
453 layout = {
454 "S","S"," "," "," "," "," ","S","S",
455 "S"," "," "," ","s"," "," "," ","S",
456 " "," ","<","S","S","S",">"," "," ",
457 " "," ","S","S","S","S","S"," "," ",
458 " ","s","S","S","S","S","S","s"," ",
459 " "," ","S","S","S","S","S"," "," ",
460 " "," ","<","S","S","S",">"," "," ",
461 "S"," "," "," ","s"," "," "," ","S",
462 "S","S"," "," "," "," "," ","S","S",
465 -- ultra pillars
467 style = "yrepeat",
468 layout = {
469 " "," "," "," "," "," "," "," "," ",
470 " ","s","^","s"," ","s","^","s"," ",
471 " ","s","s","s"," ","s","s","s"," ",
472 " ","s","s","s"," ","s","s","s"," ",
473 " "," "," "," "," "," "," "," "," ",
474 " ","s","s","s"," ","s","s","s"," ",
475 " ","s","s","s"," ","s","s","s"," ",
476 " ","s","v","s"," ","s","v","s"," ",
477 " "," "," "," "," "," "," "," "," ",
480 -- vstripes
482 style = "yrepeat",
483 layout = {
484 "S"," "," "," "," "," "," "," "," ",
485 "S"," "," ","^"," "," ","^"," "," ",
486 "S"," "," ","s"," "," ","s"," "," ",
487 "S"," "," "," "," "," "," "," "," ",
488 " "," "," ","s"," "," ","s"," "," ",
489 "S"," "," "," "," "," "," "," "," ",
490 "S"," "," ","s"," "," ","s"," "," ",
491 "S"," "," ","v"," "," ","v"," "," ",
492 "S"," "," "," "," "," "," "," "," ",
495 -- sides
497 style = "yrepeat",
498 layout = {
499 "s"," ","s"," ","s"," ","s"," ","s",
500 " "," ","v"," ","v"," ","v"," "," ",
501 "s"," "," "," "," "," "," "," ","s",
502 " "," "," "," "," "," "," "," "," ",
503 " "," "," "," "," "," "," "," ","s",
504 " "," "," "," "," "," "," "," "," ",
505 "s"," "," "," "," "," "," "," ","s",
506 " "," ","^"," ","^"," ","^"," "," ",
507 "s"," ","s"," ","s"," ","s"," ","s",
509 traps = true,
511 -- 9 pillars
513 style = "yrepeat",
514 layout = {
515 " "," "," "," "," "," "," "," "," ",
516 " "," ","^"," ","^"," ","^"," "," ",
517 " "," ","s"," ","s"," ","s"," "," ",
518 " "," "," "," "," "," "," "," "," ",
519 " "," ","s"," ","s"," ","s"," "," ",
520 " "," "," "," "," "," "," "," "," ",
521 " "," ","s"," ","s"," ","s"," "," ",
522 " "," ","v"," ","v"," ","v"," "," ",
523 " "," "," "," "," "," "," "," "," ",
525 --traps = true,
532 local layout_traps
533 local layout_traps_template = {
534 "S","S","S","S","S","S","S","S","S",
535 "?","S","?","S","?","S","?","S","S",
536 "?","S","?","S","?","S","?","S","S",
537 "?","?","?","?","?","?","?","?","S",
538 "?","?","?","?","?","?","?","?","S", -- << entrance on left side
539 "?","?","?","?","?","?","?","?","S",
540 "?","S","?","S","?","S","?","S","S",
541 "?","S","?","S","?","S","?","S","S",
542 "S","S","S","S","S","S","S","S","S"
545 local code_sandstone = {
546 [" "] = "air",
547 ["s"] = "default:sandstone",
548 ["S"] = "default:sandstonebrick",
549 ["1"] = "tsm_pyramids:deco_stone1",
550 ["2"] = "tsm_pyramids:deco_stone2",
551 ["3"] = "tsm_pyramids:deco_stone3",
552 ["^"] = "default:chest",
553 ["<"] = "default:chest",
554 [">"] = "default:chest",
555 ["v"] = "default:chest",
556 ["~"] = "default:lava_source",
557 ["t"] = "tsm_pyramids:trap",
559 local code_desert_sandstone = table.copy(code_sandstone)
560 code_desert_sandstone["s"] = "default:desert_sandstone"
561 code_desert_sandstone["1"] = "tsm_pyramids:deco_stone4"
562 code_desert_sandstone["2"] = "tsm_pyramids:deco_stone5"
563 code_desert_sandstone["3"] = "tsm_pyramids:deco_stone6"
564 code_desert_sandstone["S"] = "default:desert_sandstone_brick"
565 code_desert_sandstone["t"] = "tsm_pyramids:desert_trap"
567 local code_desert_stone = table.copy(code_sandstone)
568 code_desert_stone["s"] = "default:desert_stone_block"
569 code_desert_stone["1"] = "default:desert_stone_block"
570 code_desert_stone["2"] = "default:desert_stone_block"
571 code_desert_stone["3"] = "default:desert_stone_block"
572 code_desert_stone["S"] = "default:desert_stonebrick"
573 code_desert_stone["t"] = "air"
575 local function replace(str, iy, code_table, deco, column_style)
576 if iy < 4 and (str == "<" or str == ">" or str == "^" or str == "v") then str = " " end
577 if column_style == 1 or column_style == 2 then
578 if iy == 0 and str == "s" then str = deco[1] end
579 if iy == 3 and str == "s" then str = deco[2] end
580 elseif column_style == 3 then
581 if iy == 0 and str == "s" then str = deco[1] end
582 if iy == 2 and str == "s" then str = deco[2] end
583 elseif column_style == 4 then
584 if iy == 2 and str == "s" then str = deco[1] end
586 return code_table[str]
589 local function replace2(str, iy, code_table)
590 if iy == 0 and str == "~" then str = "t"
591 elseif iy < 3 and str == "~" then str = " " end
593 return code_table[str]
596 local function get_flat_index(x, y, width)
597 return 1 + x + y * width
600 local function rotate_layout_single(layout, width)
601 local size = width*width
602 local new_layout = {}
603 for x=0, width-1 do
604 for y=0, width-1 do
605 local symbol = layout[get_flat_index((width-1) - y, x, width)]
606 -- Rotate chest
607 if symbol == "^" then
608 symbol = "<"
609 elseif symbol == "<" then
610 symbol = "v"
611 elseif symbol == "v" then
612 symbol = ">"
613 elseif symbol == ">" then
614 symbol = "^"
616 new_layout[get_flat_index(x, y, width)] = symbol
619 return new_layout
622 local function rotate_layout(layout, width, rotations)
623 local new_layout = table.copy(layout)
624 for r=1, rotations do
625 new_layout = rotate_layout_single(new_layout, width)
627 return new_layout
630 -- pos: Position to spawn pyramid
631 -- stype: Sand type ("sandstone" or "desert")
632 -- room_id: Room layout identified (see list of rooms above)
633 -- rotations: Number of times to rotate the room (0-3)
634 function tsm_pyramids.make_room(pos, stype, room_id, rotations)
635 local code_table = code_sandstone
636 if stype == "desert_sandstone" then
637 code_table = code_desert_sandstone
638 elseif stype == "desert_stone" then
639 code_table = code_desert_stone
641 -- Select random deco block
642 local deco_ids = {"1", "2", "3"}
643 local deco = {}
644 for i=1, 2 do
645 local r = math.random(1, #deco_ids)
646 table.insert(deco, deco_ids[r])
647 table.remove(deco_ids, r)
649 local hole = {x=pos.x+7,y=pos.y+5, z=pos.z+7}
650 if room_id == nil then
651 room_id = math.random(1, #room_types)
653 local room
654 if room_id < 1 or room_id > #room_types then
655 return false, S("Incorrect room type ID: @1", room_id)
657 local room = table.copy(room_types[room_id])
658 local chests = {}
659 local column_style
660 local layout = rotate_layout(room.layout, ROOM_WIDTH, rotations)
661 if stype == "desert_stone" then
662 column_style = 0
663 else
664 column_style = math.random(0,4)
666 if room.style == "yrepeat" then
667 for iy=0,4,1 do
668 for ix=0,8,1 do
669 for iz=0,8,1 do
670 local n_str = layout[tonumber(ix*9+iz+1)]
671 local p2 = 0
672 if n_str == "<" then
673 p2 = 0
674 elseif n_str == ">" then
675 p2 = 2
676 elseif n_str == "^" then
677 p2 = 1
678 elseif n_str == "v" then
679 p2 = 3
681 local cpos = {x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}
682 local nn = replace(n_str, iy, code_table, deco, column_style)
683 minetest.set_node(cpos, {name=nn, param2=p2})
684 if nn == "default:chest" then
685 table.insert(chests, cpos)
690 else
691 minetest.log("error", "Invalid pyramid room style! room type ID="..r)
693 local sanded = room.flood_sand ~= false and stype ~= "desert_stone" and math.random(1,8) == 1
694 if #chests > 0 then
695 -- Make at least 8 attempts to fill chests
696 local filled = 0
697 while filled < 8 do
698 for c=1, #chests do
699 tsm_pyramids.fill_chest(chests[c], stype, sanded)
700 filled = filled + 1
704 if room.traps then
705 tsm_pyramids.make_traps(pos, stype, rotations)
707 if sanded then
708 tsm_pyramids.flood_sand(pos, stype)
710 return true, nil, sanded
713 local shuffle_traps = function(chance)
714 layout_traps = table.copy(layout_traps_template)
715 for a=1, #layout_traps do
716 if layout_traps[a] == "?" then
717 if math.random(1,100) <= chance then
718 layout_traps[a] = "~"
719 else
720 layout_traps[a] = "S"
726 function tsm_pyramids.make_traps(pos, stype, rotations)
727 local code_table = code_sandstone
728 if stype == "desert_sandstone" then
729 code_table = code_desert_sandstone
730 elseif stype == "desert_stone" then
731 code_table = code_desert_stone
733 shuffle_traps(math.random(10,100))
734 local hole = {x=pos.x+7,y=pos.y, z=pos.z+7}
735 local layout = rotate_layout(layout_traps, ROOM_WIDTH, rotations)
736 for iy=0,4,1 do
737 for ix=0,8,1 do
738 for iz=0,8,1 do
739 local n_str = layout[tonumber(ix*9+iz+1)]
740 local p2 = 0
741 minetest.set_node({x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}, {name=replace2(n_str, iy, code_table), param2=p2})
747 function tsm_pyramids.flood_sand(pos, stype)
748 local set_to_sand = {}
749 local nn = "default:sand"
750 if stype == "desert_sandstone" or stype == "desert_stone" then
751 nn = "default:desert_sand"
753 local hole = {x=pos.x+7,y=pos.y+1, z=pos.z+7}
754 local maxh = math.random(1,4)
755 local chance = math.random(1,7)
756 for ix=0,8,1 do
757 for iz=0,8,1 do
758 if math.random(1,chance) == 1 then
759 local h = math.random(1,maxh)
760 for iy=0,h,1 do
761 local p = {x=hole.x+ix,y=hole.y+iy,z=hole.z+iz}
762 if minetest.get_node(p).name == "air" then
763 table.insert(set_to_sand, p)
769 minetest.bulk_set_node(set_to_sand, {name=nn})