Fix crash if mummy dies in fire
[minetest_pyramids/tsm_pyramids.git] / room.lua
bloba794c6ef06eb9cb047d6d8a0b48a2598671287d8
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 " ","c"," ","c"," ","c"," ","c"," ",
15 " "," "," "," "," "," "," "," "," ",
16 " "," "," "," "," "," "," "," "," ",
17 " "," "," "," "," "," "," "," "," ",
18 " ","c"," ","c"," ","c"," ","c"," ",
19 " ","v"," ","v"," ","v"," ","v"," ",
20 " "," "," "," "," "," "," "," "," "
22 traps = true,
24 -- Hieroglyph walls
26 style = "yrepeat",
27 layout = {
28 "s","h","h","h","h","h","h","h","s",
29 "h"," "," "," "," "," "," "," ","h",
30 "h"," "," "," "," "," "," "," ","h",
31 "h"," "," "," "," "," "," "," ","h",
32 " "," "," "," ","<"," "," "," ","h",
33 "h"," "," "," "," "," "," "," ","h",
34 "h"," "," "," "," "," "," "," ","h",
35 "h"," "," "," "," "," "," "," ","h",
36 "s","h","h","h","h","h","h","h","s"
39 -- 4 large pillars
41 style = "yrepeat",
42 layout = {
43 " "," "," "," ","v"," "," "," "," ",
44 " ","c","c"," "," "," ","c","c"," ",
45 " ","c","c"," "," "," ","c","c"," ",
46 " "," "," "," "," "," "," "," "," ",
47 " "," "," "," "," "," "," "," ","<",
48 " "," "," "," "," "," "," "," "," ",
49 " ","c","c"," "," "," ","c","c"," ",
50 " ","c","c"," "," "," ","c","c"," ",
51 " "," "," "," ","^"," "," "," "," "
53 traps = true,
55 -- hidden room
57 style = "yrepeat",
58 layout = {
59 " "," "," "," "," "," "," "," "," ",
60 " "," "," "," "," "," "," "," "," ",
61 " "," ","c","S","c","S","c"," "," ",
62 " "," ","S"," "," "," ","S"," "," ",
63 " "," ","c"," ",">"," ","c"," ","<",
64 " "," ","S"," "," "," ","S"," "," ",
65 " "," ","c","S","c","S","c"," "," ",
66 " "," "," "," "," "," "," "," "," ",
67 " "," "," "," "," "," "," "," "," "
70 -- spiral 1
72 style = "yrepeat",
73 layout = {
74 " "," "," "," "," "," "," "," "," ",
75 " ","S","S","S","S","S","S","S"," ",
76 " ","S"," "," "," "," "," ","S"," ",
77 " ","S"," ","c","c","c"," ","S"," ",
78 " ","S"," ","c","v","c"," ","S"," ",
79 "S","S"," ","c"," ","c"," ","S"," ",
80 "S","S"," ","c"," "," "," ","S"," ",
81 "v","S"," ","S","S","S","S","S"," ",
82 " ","S"," "," "," "," "," "," "," "
85 -- spiral 2
87 style = "yrepeat",
88 layout = {
89 " "," "," "," "," "," "," "," "," ",
90 " ","S","S","S","S","S","S","S"," ",
91 " "," "," ","c"," "," "," ","S"," ",
92 "S","S"," ","c"," ","c"," ","S"," ",
93 " ","S"," ","c","^","c"," ","S"," ",
94 " ","S"," ","c","c","c"," ","S"," ",
95 " ","S"," "," "," "," "," ","S"," ",
96 " ","S","S","S","S","S","S","S"," ",
97 " "," "," "," "," "," "," "," "," "
100 -- pillar mania
102 style = "yrepeat",
103 layout = {
104 " "," ","v"," ","v"," ","v"," ","v",
105 " ","c"," ","c"," ","c"," ","c"," ",
106 " "," "," "," "," "," "," "," "," ",
107 " ","c"," ","c"," ","c"," ","c"," ",
108 " "," "," "," "," "," "," "," "," ",
109 " ","c"," ","c"," ","c"," ","c"," ",
110 " "," "," "," "," "," "," "," "," ",
111 " ","c"," ","c"," ","c"," ","c"," ",
112 " "," ","^"," ","^"," ","^"," ","^",
114 traps = true,
116 -- plusses
118 style = "yrepeat",
119 layout = {
120 "c"," "," "," "," "," "," "," ","c",
121 " "," ","c",">"," ","<","c"," "," ",
122 " ","c","s","c"," ","c","s","c"," ",
123 " "," ","c"," "," "," ","c"," "," ",
124 " "," "," "," ","<"," "," "," "," ",
125 " "," ","c"," "," "," ","c"," "," ",
126 " ","c","s","c"," ","c","s","c"," ",
127 " "," ","c",">"," ","<","c"," "," ",
128 "c"," "," "," "," "," "," "," ","c",
130 traps = true,
132 -- diamond
134 style = "yrepeat",
135 layout = {
136 ">","s","s","c","c","c","s","s","s",
137 "s","s","c"," "," "," ","c","s","s",
138 "s","c"," "," "," "," "," ","c","s",
139 "c"," "," "," "," "," "," "," ","c",
140 " "," "," "," "," "," "," ","<","c",
141 "c"," "," "," "," "," "," "," ","c",
142 "s","c"," "," "," "," "," ","c","s",
143 "s","s","c"," "," "," ","c","s","s",
144 ">","s","s","c","c","c","s","s","s",
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","c",">"," "," "," ",
183 "S","c","S","c","S","c","S"," "," ",
184 " "," "," "," "," "," "," "," "," ",
185 " "," "," "," "," "," "," "," "," ",
186 " "," "," "," "," "," "," "," "," ",
187 "S","c","S","c","S","c","S"," "," ",
188 "S","S","S","S","c",">"," "," "," ",
189 "S","S","S","S","S"," "," "," "," ",
191 traps = true,
193 -- hallway 4
195 style = "yrepeat",
196 layout = {
197 "S","S","S","S","S","v","S","S","S",
198 "S","S","S","S","S","S","S","S","S",
199 "c","S","c","S","c","S","c","S","c",
200 " "," "," "," "," "," "," "," "," ",
201 " "," "," "," "," "," "," "," ","<",
202 " "," "," "," "," "," "," "," "," ",
203 "c","S","c","S","c","S","c","S","c",
204 "S","S","S","S","S","S","S","S","S",
205 "S","S","S","S","S","^","S","S","S",
208 -- tiny
210 style = "yrepeat",
211 layout = {
212 "S","S","S","S","S","S","S","S","v",
213 "S","S","S","S","S","S","S","S"," ",
214 "S","S","S","S","S","S","S","S"," ",
215 "S","S","S"," "," "," ","S","S"," ",
216 " "," "," "," ","<"," ","S","S"," ",
217 "S","S","S"," "," "," ","S","S"," ",
218 "S","S","S","S","S","S","S","S"," ",
219 "S","S","S","S","S","S","S","S"," ",
220 "S","S","S","S","S","S","S","S","^",
223 -- small
225 style = "yrepeat",
226 layout = {
227 "S","S","S","S","S","S","S","S","S",
228 "S","S","S","S","S","S","S","S","S",
229 "S","S"," ","v"," ","v"," ","S","S",
230 "S","S",">"," "," "," ","<","S"," ",
231 " "," "," "," ","c"," "," ","S"," ",
232 "S","S",">"," "," "," ","<","S"," ",
233 "S","S"," ","^"," ","^"," ","S","S",
234 "S","S","S","S","S","S","S","S","S",
235 "S","S","S","S","S","S","S","S","S",
238 -- small 2
240 style = "yrepeat",
241 layout = {
242 " "," "," "," "," "," "," "," "," ",
243 " ","S","S","S","S","S","S","S"," ",
244 " ","S"," "," ","v"," "," ","S"," ",
245 "S","S"," "," "," "," "," ","S"," ",
246 " "," "," "," "," "," ","<","S"," ",
247 "S","S"," "," "," "," "," ","S"," ",
248 " ","S"," "," ","^"," "," ","S"," ",
249 " ","S","S","S","S","S","S","S"," ",
250 " "," "," "," "," "," "," "," "," ",
253 -- big pillar
255 style = "yrepeat",
256 layout = {
257 " "," "," "," "," "," "," "," "," ",
258 " "," "," "," "," "," "," "," "," ",
259 " "," "," "," ","^"," "," "," "," ",
260 " "," "," ","c","c","c"," "," "," ",
261 " "," ","<","c","S","c",">"," "," ",
262 " "," "," ","c","c","c"," "," "," ",
263 " "," "," "," ","v"," "," "," "," ",
264 " "," "," "," "," "," "," "," "," ",
265 " "," "," "," "," "," "," "," "," ",
267 traps = true,
269 -- pacman
271 style = "yrepeat",
272 layout = {
273 " "," "," "," "," "," "," "," "," ",
274 " "," "," "," "," "," "," "," "," ",
275 " "," "," ","c","c","c"," "," "," ",
276 " "," ","c","c","v","c","c"," "," ",
277 " "," ","c",">"," "," "," "," "," ",
278 " "," ","c","c","^","c","c"," "," ",
279 " "," "," ","c","c","c"," "," "," ",
280 " "," "," "," "," "," "," "," "," ",
281 " "," "," "," "," "," "," "," "," ",
283 traps = true,
285 -- the wall
287 style = "yrepeat",
288 layout = {
289 "S","S","S","S","S","S","S"," ","<",
290 "s","c","s","c","s","c","s"," ","c",
291 "c"," "," "," "," "," ","c"," ","<",
292 "s"," "," "," "," "," ","s"," ","c",
293 " "," "," "," "," ","<","c"," ","<",
294 "s"," "," "," "," "," ","s"," ","c",
295 "c"," "," "," "," "," ","c"," ","<",
296 "s","c","s","c","s","c","s"," ","c",
297 "S","S","S","S","S","S","S"," ","<",
299 traps = true,
301 -- split
303 style = "yrepeat",
304 layout = {
305 " "," "," "," "," "," "," "," "," ",
306 " "," "," "," "," "," "," "," "," ",
307 " "," "," "," "," "," "," "," "," ",
308 " "," "," ","^"," ","^"," "," "," ",
309 " "," "," ","c"," ","c"," "," "," ",
310 " "," "," ","v"," ","v"," "," "," ",
311 " "," "," "," "," "," "," "," "," ",
312 " "," "," "," "," "," "," "," "," ",
313 " "," "," "," "," "," "," "," "," ",
315 traps = true,
317 -- 4 small pillars
319 style = "yrepeat",
320 layout = {
321 " "," "," "," "," "," "," "," "," ",
322 " "," "," "," ","^"," "," "," "," ",
323 " "," "," "," ","c"," "," "," "," ",
324 " "," "," "," "," "," "," "," "," ",
325 " ","<","c"," "," "," ","c",">"," ",
326 " "," "," "," "," "," "," "," "," ",
327 " "," "," "," ","c"," "," "," "," ",
328 " "," "," "," ","v"," "," "," "," ",
329 " "," "," "," "," "," "," "," "," ",
331 traps = true,
333 -- 6 pillars
335 style = "yrepeat",
336 layout = {
337 " "," "," "," "," "," "," "," "," ",
338 " "," ","^"," ","^"," ","^"," "," ",
339 " "," ","c"," ","c"," ","c"," "," ",
340 " "," "," "," "," "," "," "," "," ",
341 " "," "," "," "," "," "," "," "," ",
342 " "," "," "," "," "," "," "," "," ",
343 " "," ","c"," ","c"," ","c"," "," ",
344 " "," ","v"," ","v"," ","v"," "," ",
345 " "," "," "," "," "," "," "," "," ",
347 traps = true,
349 -- stripes
351 style = "yrepeat",
352 layout = {
353 " ","S","v","S","v","S","v","S","v",
354 " ","S"," ","S"," ","S"," ","S"," ",
355 " ","c"," ","c"," ","c"," ","c"," ",
356 " "," "," "," "," "," "," "," "," ",
357 " "," "," "," "," "," "," "," "," ",
358 " "," "," "," "," "," "," "," "," ",
359 " ","c"," ","c"," ","c"," ","c"," ",
360 " ","S"," ","S"," ","S"," ","S"," ",
361 " ","S","^","S","^","S","^","S","^",
363 traps = true,
365 -- inside
367 style = "yrepeat",
368 layout = {
369 " "," "," "," "," "," "," "," "," ",
370 " ","c"," "," "," "," "," ","c"," ",
371 " "," "," "," "," "," "," "," "," ",
372 " "," "," ","c","S","c"," "," "," ",
373 " "," "," ","S",">"," "," "," "," ",
374 " "," "," ","c","S","c"," "," "," ",
375 " "," "," "," "," "," "," "," "," ",
376 " ","c"," "," "," "," "," ","c"," ",
377 " "," "," "," "," "," "," "," "," ",
380 -- 1 chest
382 style = "yrepeat",
383 layout = {
384 " "," "," "," "," "," "," "," "," ",
385 " "," "," "," "," "," "," "," "," ",
386 " "," "," "," "," "," "," "," "," ",
387 " "," "," "," "," "," "," "," "," ",
388 " "," "," "," ","<"," "," "," "," ",
389 " "," "," "," "," "," "," "," "," ",
390 " "," "," "," "," "," "," "," "," ",
391 " "," "," "," "," "," "," "," "," ",
392 " "," "," "," "," "," "," "," "," ",
394 traps = true,
396 -- 2 chests
398 style = "yrepeat",
399 layout = {
400 " "," "," "," "," "," "," "," "," ",
401 " "," "," "," "," "," "," "," ","<",
402 " "," "," "," "," "," "," "," "," ",
403 " "," "," "," "," "," "," "," "," ",
404 " "," "," "," "," "," "," "," "," ",
405 " "," "," "," "," "," "," "," "," ",
406 " "," "," "," "," "," "," "," "," ",
407 " "," "," "," "," "," "," "," ","<",
408 " "," "," "," "," "," "," "," "," ",
410 traps = true,
412 -- X
414 style = "yrepeat",
415 layout = {
416 "c"," "," "," "," "," "," "," ","c",
417 "c","c",">"," "," "," ","<","c","c",
418 " ","c","c"," "," "," ","c","c"," ",
419 " "," ","c","c"," ","c","c"," "," ",
420 " "," "," "," "," "," "," "," "," ",
421 " "," ","c","c"," ","c","c"," "," ",
422 " ","c","c"," "," "," ","c","c"," ",
423 "c","c",">"," "," "," ","<","c","c",
424 "c"," "," "," "," "," "," "," ","c",
427 -- split 2
429 style = "yrepeat",
430 layout = {
431 "S","S","S","S","S","S","S","S","S",
432 "S","S","S"," "," "," "," "," "," ",
433 "S","S","S"," "," "," "," "," "," ",
434 "S","S","S"," "," ","^","^","^","^",
435 " "," "," "," "," ","c","c","c","c",
436 "S","S","S"," "," ","v","v","v","v",
437 "S","S","S"," "," "," "," "," "," ",
438 "S","S","S"," "," "," "," "," "," ",
439 "S","S","S","S","S","S","S","S","S",
442 -- split 3
444 style = "yrepeat",
445 layout = {
446 " "," "," "," "," "," "," "," "," ",
447 " "," "," "," "," "," "," "," "," ",
448 " "," "," "," "," "," "," "," "," ",
449 " ","^"," ","^"," ","^"," ","^"," ",
450 " ","c"," ","c"," ","c"," ","c"," ",
451 " ","v"," ","v"," ","v"," ","v"," ",
452 " "," "," "," "," "," "," "," "," ",
453 " "," "," "," "," "," "," "," "," ",
454 " "," "," "," "," "," "," "," "," ",
456 traps = true,
458 -- diamond 2
460 style = "yrepeat",
461 layout = {
462 "S","S"," "," "," "," "," ","S","S",
463 "S"," "," "," ","c"," "," "," ","S",
464 " "," ","<","S","S","S",">"," "," ",
465 " "," ","S","S","S","S","S"," "," ",
466 " ","c","S","S","S","S","S","c"," ",
467 " "," ","S","S","S","S","S"," "," ",
468 " "," ","<","S","S","S",">"," "," ",
469 "S"," "," "," ","c"," "," "," ","S",
470 "S","S"," "," "," "," "," ","S","S",
472 traps = true,
474 -- ultra pillars
476 style = "yrepeat",
477 layout = {
478 " "," "," "," "," "," "," "," "," ",
479 " ","c","^","c"," ","c","^","c"," ",
480 " ","c","c","c"," ","c","c","c"," ",
481 " ","c","c","c"," ","c","c","c"," ",
482 " "," "," "," "," "," "," "," "," ",
483 " ","c","c","c"," ","c","c","c"," ",
484 " ","c","c","c"," ","c","c","c"," ",
485 " ","c","v","c"," ","c","v","c"," ",
486 " "," "," "," "," "," "," "," "," ",
489 -- vstripes
491 style = "yrepeat",
492 layout = {
493 "S"," "," "," "," "," "," "," "," ",
494 "S"," "," ","^"," "," ","^"," "," ",
495 "S"," "," ","c"," "," ","c"," "," ",
496 "S"," "," "," "," "," "," "," "," ",
497 " "," "," ","c"," "," ","c"," "," ",
498 "S"," "," "," "," "," "," "," "," ",
499 "S"," "," ","c"," "," ","c"," "," ",
500 "S"," "," ","v"," "," ","v"," "," ",
501 "S"," "," "," "," "," "," "," "," ",
503 traps = true,
505 -- sides
507 style = "yrepeat",
508 layout = {
509 "c"," ","c"," ","c"," ","c"," ","c",
510 " "," ","v"," ","v"," ","v"," "," ",
511 "c"," "," "," "," "," "," "," ","c",
512 " "," "," "," "," "," "," "," "," ",
513 " "," "," "," "," "," "," "," ","c",
514 " "," "," "," "," "," "," "," "," ",
515 "c"," "," "," "," "," "," "," ","c",
516 " "," ","^"," ","^"," ","^"," "," ",
517 "c"," ","c"," ","c"," ","c"," ","c",
519 traps = true,
521 -- 9 pillars
523 style = "yrepeat",
524 layout = {
525 " "," "," "," "," "," "," "," "," ",
526 " "," ","^"," ","^"," ","^"," "," ",
527 " "," ","c"," ","c"," ","c"," "," ",
528 " "," "," "," "," "," "," "," "," ",
529 " "," ","c"," ","c"," ","c"," "," ",
530 " "," "," "," "," "," "," "," "," ",
531 " "," ","c"," ","c"," ","c"," "," ",
532 " "," ","v"," ","v"," ","v"," "," ",
533 " "," "," "," "," "," "," "," "," ",
535 traps = true,
537 -- Ankh statue
539 style = "stacked",
540 layout = { {
541 " "," "," "," "," "," "," "," "," ",
542 " "," "," "," "," "," "," "," "," ",
543 " "," "," "," "," "," "," "," "," ",
544 " "," "," "," "," "," "," "," "," ",
545 " "," "," "," ","s",">"," "," "," ",
546 " "," "," "," "," "," "," "," "," ",
547 " "," "," "," "," "," "," "," "," ",
548 " "," "," "," "," "," "," "," "," ",
549 " "," "," "," "," "," "," "," "," ",
551 " "," "," "," "," "," "," "," "," ",
552 " "," "," "," "," "," "," "," "," ",
553 " "," "," "," "," "," "," "," "," ",
554 " "," "," "," ","s"," "," "," "," ",
555 " "," "," "," ","s"," "," "," "," ",
556 " "," "," "," ","s"," "," "," "," ",
557 " "," "," "," "," "," "," "," "," ",
558 " "," "," "," "," "," "," "," "," ",
559 " "," "," "," "," "," "," "," "," ",
561 " "," "," "," "," "," "," "," "," ",
562 " "," "," "," "," "," "," "," "," ",
563 " "," "," "," "," "," "," "," "," ",
564 " "," "," "," "," "," "," "," "," ",
565 " "," "," "," ","s"," "," "," "," ",
566 " "," "," "," "," "," "," "," "," ",
567 " "," "," "," "," "," "," "," "," ",
568 " "," "," "," "," "," "," "," "," ",
569 " "," "," "," "," "," "," "," "," ",
571 " "," "," "," "," "," "," "," "," ",
572 " "," "," "," "," "," "," "," "," ",
573 " "," "," "," "," "," "," "," "," ",
574 " "," "," "," ","s"," "," "," "," ",
575 " "," "," "," "," "," "," "," "," ",
576 " "," "," "," ","s"," "," "," "," ",
577 " "," "," "," "," "," "," "," "," ",
578 " "," "," "," "," "," "," "," "," ",
579 " "," "," "," "," "," "," "," "," ",
581 " "," "," "," "," "," "," "," "," ",
582 " "," "," "," "," "," "," "," "," ",
583 " "," "," "," "," "," "," "," "," ",
584 " "," "," "," "," "," "," "," "," ",
585 " "," "," "," ","s"," "," "," "," ",
586 " "," "," "," "," "," "," "," "," ",
587 " "," "," "," "," "," "," "," "," ",
588 " "," "," "," "," "," "," "," "," ",
589 " "," "," "," "," "," "," "," "," ",
591 stype = "desert_sandstone",
592 wall = {
593 "S","S","S","S","S","S","S","S","S",
594 "s","1","s","1","s","1","s","1","s",
595 "S","S","S","S","S","S","S","S","S",
596 "1","s","1","s","1","s","1","s","1",
597 "S","S","S","S","S","S","S","S","S",
600 --[[
601 -- Cactus room 1
603 style = "stacked",
604 layout_offset = -1,
605 layout_height = 5,
606 layout = {{
607 "s","s","s","s","s","s","s","s","s",
608 "s","a","a","a","a","a","a","a","s",
609 "s","a","a","a","a","a","a","a","s",
610 "s","a","a","a","a","a","a","a","s",
611 "s","a","a","a","a","a","a","a","s",
612 "s","a","a","a","a","a","a","a","s",
613 "s","a","a","a","a","a","a","a","s",
614 "s","a","a","a","a","a","a","a","s",
615 "s","s","s","s","s","s","s","s","s",
617 " "," "," "," "," "," "," "," ","<",
618 " ","C"," ","C"," ","C"," ","C"," ",
619 " "," "," "," "," "," "," "," "," ",
620 " ","C"," ","C"," ","C"," ","C"," ",
621 " "," "," "," "," "," "," "," "," ",
622 " ","C"," ","C"," ","C"," ","C"," ",
623 " "," "," "," "," "," "," "," "," ",
624 " ","C"," ","C"," ","C"," ","C"," ",
625 " "," "," "," "," "," "," "," ","<",
628 wall = {
629 "S","S","S","S","S","S","S","S","S",
630 "S","S","S","S","S","S","S","S","S",
631 "s","3","s","3","s","3","s","3","s",
632 "S","S","S","S","S","S","S","S","S",
633 "S","S","S","S","S","S","S","S","S",
635 stype = "desert_sandstone",
638 -- Cactus room 2
640 style = "stacked",
641 layout_offset = -1,
642 layout_height = 5,
643 layout = {{
644 "S","S","S","S","S","S","S","S","S",
645 "S","s","s","s","s","s","s","s","S",
646 "S","s","a","a","a","a","a","s","S",
647 "S","s","a","a","a","a","a","s","S",
648 "S","s","a","a","a","a","a","s","S",
649 "S","s","a","a","a","a","a","s","S",
650 "S","s","a","a","a","a","a","s","S",
651 "S","s","s","s","s","s","s","s","S",
652 "S","S","S","S","S","S","S","S","S",
654 " "," "," "," "," "," "," "," ","<",
655 " "," "," "," "," "," "," "," "," ",
656 " "," ","C"," ","C"," ","C"," "," ",
657 " "," "," "," "," "," "," "," "," ",
658 " "," ","C"," ","C"," ","C"," "," ",
659 " "," "," "," "," "," "," "," "," ",
660 " "," ","C"," ","C"," ","C"," "," ",
661 " "," "," "," "," "," "," "," "," ",
662 " "," "," "," "," "," "," "," ","<",
665 wall = {
666 "S","S","S","S","S","S","S","S","S",
667 "S","S","S","S","S","S","S","S","S",
668 "s","3","s","3","s","3","s","3","s",
669 "S","S","S","S","S","S","S","S","S",
670 "S","S","S","S","S","S","S","S","S",
672 stype = "desert_sandstone",
674 -- Sun room
676 style = "stacked",
677 layout_offset = 0,
678 layout_height = 8,
679 layout = {{
680 "n","s","s","s","s","s","s","s","n",
681 "s","n","s","s","s","s","s","n","s",
682 "s","s","n","n","n","n","n","s","s",
683 "s","s","n","s","s","s","n","s","s",
684 "s","s","n","s","s","s","n","s","s",
685 "s","s","n","s","s","s","n","s","s",
686 "s","s","n","n","n","n","n","s","s",
687 "s","n","s","s","s","s","s","n","s",
688 "n","s","s","s","s","s","s","s","n",
690 " "," "," "," "," "," "," "," "," ",
691 " "," "," "," "," "," "," "," "," ",
692 " "," "," "," "," "," "," "," "," ",
693 " "," "," "," "," "," "," "," "," ",
694 " "," "," "," ","<"," "," "," "," ",
695 " "," "," "," "," "," "," "," "," ",
696 " "," "," "," "," "," "," "," "," ",
697 " "," "," "," "," "," "," "," "," ",
698 " "," "," "," "," "," "," "," "," ",
700 "n","s","s","s","s","s","s","s","n",
701 "s","n","s","s","s","s","s","n","s",
702 "s","s","n","n","n","n","n","s","s",
703 "s","s","n","s","s","s","n","s","s",
704 "s","s","n","s","s","s","n","s","s",
705 "s","s","n","s","s","s","n","s","s",
706 "s","s","n","n","n","n","n","s","s",
707 "s","n","s","s","s","s","s","n","s",
708 "n","s","s","s","s","s","s","s","n",
710 wall = {
711 "S","S","S","S","S","S","S","S","S",
712 "s","3","s","3","s","3","s","3","s",
713 "S","S","S","S","S","S","S","S","S",
714 "3","s","3","s","3","s","3","s","3",
715 "S","S","S","S","S","S","S","S","S",
717 stype = "sandstone",
718 open_roof = true,
720 -- Attic
722 style = "stacked",
723 layout_height = 6,
724 layout_offset = 1,
725 layout = { {
726 " "," "," "," "," "," "," "," "," ",
727 " ","S","S","S"," ","S","S","S"," ",
728 " ","S"," "," "," "," "," ","S"," ",
729 " ","S"," "," "," "," "," ","S"," ",
730 " "," "," "," ","c",">"," "," "," ",
731 " ","S"," "," "," "," "," ","S"," ",
732 " ","S"," "," "," "," "," ","S"," ",
733 " ","S","S","S"," ","S","S","S"," ",
734 " "," "," "," "," "," "," "," "," ",
736 " "," "," "," "," "," "," "," "," ",
737 " ","S","S","S"," ","S","S","S"," ",
738 " ","S"," "," "," "," "," ","S"," ",
739 " ","S"," "," "," "," "," ","S"," ",
740 " "," "," "," ","c"," "," "," "," ",
741 " ","S"," "," "," "," "," ","S"," ",
742 " ","S"," "," "," "," "," ","S"," ",
743 " ","S","S","S"," ","S","S","S"," ",
744 " "," "," "," "," "," "," "," "," ",
746 " "," "," "," "," "," "," "," "," ",
747 " ","S","S","S"," ","S","S","S"," ",
748 " ","S"," "," "," "," "," ","S"," ",
749 " ","S"," "," "," "," "," ","S"," ",
750 " "," "," "," ","c"," "," "," "," ",
751 " ","S"," "," "," "," "," ","S"," ",
752 " ","S"," "," "," "," "," ","S"," ",
753 " ","S","S","S"," ","S","S","S"," ",
754 " "," "," "," "," "," "," "," "," ",
756 "s","s","s","s","s","s","s","s","s",
757 "s","S","S","S","S","S","S","S","s",
758 "s","S","s","s","s","s","s","S","s",
759 "s","S","s","s","s","s","s","S","s",
760 "s","S","s","s","s","s","s","S","s",
761 "s","S","s","s","s","s","s","S","s",
762 "s","S","s","s","s","s","s","S","s",
763 "s","S","S","S","S","S","S","S","c",
764 "s","s","s","s","s","s","s","s","s",
766 "S","S","S","S","S","S","S","S","S",
767 "S","S","S","S","v","S","S","S","S",
768 "S","S"," "," "," "," "," ","S","S",
769 "S","S"," "," "," "," "," ","S","S",
770 "S",">"," "," "," "," "," ","<","S",
771 "S","S"," "," "," "," "," ","S","S",
772 "S","S"," "," "," "," "," ","S","S",
773 "S","S","S","S","^","S","S","S","S",
774 "S","S","S","S","S","S","S","S","S",
776 "S","S","S","S","S","S","S","S","S",
777 "S","S","S","S","S","S","S","S","S",
778 "S","S"," "," "," "," "," ","S","S",
779 "S","S"," "," "," "," "," ","S","S",
780 "S","S"," "," "," "," "," ","S","S",
781 "S","S"," "," "," "," "," ","S","S",
782 "S","S"," "," "," "," "," ","S","S",
783 "S","S","S","S","S","S","S","S","S",
784 "S","S","S","S","S","S","S","S","S",
789 local layout_traps_template = {
790 "S","S","S","S","S","S","S","S","S",
791 "?","?","?","?","?","?","?","?","S",
792 "?","?","?","?","?","?","?","?","S",
793 "?","?","?","?","?","?","?","?","S",
794 "?","?","?","?","?","?","?","?","S", -- << entrance on left side
795 "?","?","?","?","?","?","?","?","S",
796 "?","?","?","?","?","?","?","?","S",
797 "?","?","?","?","?","?","?","?","S",
798 "S","S","S","S","S","S","S","S","S"
801 local code_sandstone = {
802 [" "] = "air",
803 ["c"] = "default:sandstone",
804 ["s"] = "default:sandstone",
805 ["n"] = "default:desert_sandstone",
806 ["h"] = "default:sandstone",
807 ["S"] = "default:sandstonebrick",
808 ["1"] = "tsm_pyramids:deco_stone1",
809 ["2"] = "tsm_pyramids:deco_stone2",
810 ["3"] = "tsm_pyramids:deco_stone3",
811 ["^"] = "default:chest",
812 ["<"] = "default:chest",
813 [">"] = "default:chest",
814 ["v"] = "default:chest",
815 ["~"] = "default:lava_source",
816 ["t"] = "tsm_pyramids:trap",
817 ["C"] = "default:large_cactus_seedling",
818 ["a"] = "default:sand",
820 local code_desert_sandstone = table.copy(code_sandstone)
821 code_desert_sandstone["c"] = "default:desert_sandstone"
822 code_desert_sandstone["s"] = "default:desert_sandstone"
823 code_desert_sandstone["n"] = "default:sandstone"
824 code_desert_sandstone["h"] = "default:desert_sandstone"
825 code_desert_sandstone["1"] = "tsm_pyramids:deco_stone4"
826 code_desert_sandstone["2"] = "tsm_pyramids:deco_stone5"
827 code_desert_sandstone["3"] = "tsm_pyramids:deco_stone6"
828 code_desert_sandstone["S"] = "default:desert_sandstone_brick"
829 code_desert_sandstone["t"] = "tsm_pyramids:desert_trap"
830 code_desert_sandstone["a"] = "default:desert_sand"
832 local code_desert_stone = table.copy(code_sandstone)
833 code_desert_stone["c"] = "default:desert_stone_block"
834 code_desert_stone["s"] = "default:desert_stone_block"
835 code_desert_stone["n"] = "default:desert_stone_block"
836 code_desert_stone["h"] = "default:desert_stone_block"
837 code_desert_stone["1"] = "default:desert_stone_block"
838 code_desert_stone["2"] = "default:desert_stone_block"
839 code_desert_stone["3"] = "default:desert_stone_block"
840 code_desert_stone["S"] = "default:desert_stonebrick"
841 code_desert_stone["t"] = "air"
842 code_desert_stone["a"] = "default:desert_sand"
844 local function replace(str, iy, code_table, deco, column_style)
845 if iy < 4 and (str == "<" or str == ">" or str == "^" or str == "v") then str = " " end
846 if str == "h" then
847 local r = math.random(0,3)
848 if r > 0 then
849 str = deco[r]
850 else
851 str = "c"
853 elseif column_style == 1 or column_style == 2 then
854 if iy == 0 and str == "c" then str = deco[1] end
855 if iy == 3 and str == "c" then str = deco[2] end
856 elseif column_style == 3 then
857 if iy == 0 and str == "c" then str = deco[1] end
858 if iy == 2 and str == "c" then str = deco[2] end
859 elseif column_style == 4 then
860 if iy == 2 and str == "c" then str = deco[1] end
862 return code_table[str]
865 local function replace2(str, iy, depth, code_table, trap_node)
866 if iy == depth then
867 -- Sandstone at the bottom-most layer
868 str = "s"
869 elseif iy == depth-1 then
870 -- Brick at the layer above
871 str = "S"
872 elseif iy == 0 and str == "~" then
873 -- Trap stones at the top layer
874 str = "t"
875 elseif str == "~" then
876 if iy < depth-3 then
877 -- Air below the trap stones
878 str = " "
879 else
880 str = trap_node
883 -- Everything else is untouched (will stay pyramid material)
885 return code_table[str]
888 local function get_flat_index(x, y, width)
889 return 1 + x + y * width
892 local function rotate_layout_single(layout, width)
893 local size = width*width
894 local new_layout = {}
895 for x=0, width-1 do
896 for y=0, width-1 do
897 local symbol = layout[get_flat_index((width-1) - y, x, width)]
898 -- Rotate chest
899 if symbol == "^" then
900 symbol = "<"
901 elseif symbol == "<" then
902 symbol = "v"
903 elseif symbol == "v" then
904 symbol = ">"
905 elseif symbol == ">" then
906 symbol = "^"
908 new_layout[get_flat_index(x, y, width)] = symbol
911 return new_layout
914 local function rotate_layout(layout, width, rotations)
915 local new_layout = table.copy(layout)
916 for r=1, rotations do
917 new_layout = rotate_layout_single(new_layout, width)
919 return new_layout
922 -- pos: Position to spawn pyramid
923 -- stype: Sand type ("sandstone" or "desert")
924 -- room_id: Room layout identified (see list of rooms above)
925 -- rotations: Number of times to rotate the room (0-3)
926 function tsm_pyramids.make_room(pos, stype, room_id, rotations)
927 local code_table = code_sandstone
928 if stype == "desert_sandstone" then
929 code_table = code_desert_sandstone
930 elseif stype == "desert_stone" then
931 code_table = code_desert_stone
933 -- Select random deco block
934 local deco_ids = {"1", "2", "3"}
935 local deco = {}
936 for i=1, 3 do
937 local r = math.random(1, #deco_ids)
938 table.insert(deco, deco_ids[r])
939 table.remove(deco_ids, r)
941 local hole = {x=pos.x+7,y=pos.y+5, z=pos.z+7}
942 if room_id == nil then
943 room_id = math.random(1, #room_types)
945 local room
946 if room_id < 1 or room_id > #room_types then
947 return false, S("Incorrect room type ID: @1", room_id)
949 local room = table.copy(room_types[room_id])
950 local tries = 0
951 while tries < #room_types do
952 if room.stype and room.stype ~= stype then
953 room_id = room_id + 1
954 if room_id > #room_types then
955 room_id = 1
957 room = table.copy(room_types[room_id])
958 else
959 break
961 tries = tries + 1
963 local chests = {}
964 local column_style
965 if stype == "desert_stone" then
966 column_style = 0
967 else
968 column_style = math.random(0,4)
970 -- Custom room walls
971 if room.wall then
972 for iy=0,4,1 do
973 for ie=0,8,1 do
974 local nn = code_table[room.wall[iy*9+ie+1]]
975 minetest.set_node({x=hole.x+ie, y=hole.y-iy, z=hole.z-1}, {name=nn})
976 minetest.set_node({x=hole.x-1, y=hole.y-iy, z=hole.z+ie}, {name=nn})
978 minetest.set_node({x=hole.x+ie, y=hole.y-iy, z=hole.z+9}, {name=nn})
979 minetest.set_node({x=hole.x+9, y=hole.y-iy, z=hole.z+ie}, {name=nn})
983 local layout
984 -- Place the room nodes
985 if room.style == "yrepeat" then
986 layout = rotate_layout(room.layout, ROOM_WIDTH, rotations)
987 for iy=0,4,1 do
988 for ix=0,8,1 do
989 for iz=0,8,1 do
990 local n_str = layout[ix*9+iz+1]
991 local p2 = 0
992 if n_str == "<" then
993 p2 = 0
994 elseif n_str == ">" then
995 p2 = 2
996 elseif n_str == "^" then
997 p2 = 1
998 elseif n_str == "v" then
999 p2 = 3
1001 local cpos = {x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}
1002 local nn = replace(n_str, iy, code_table, deco, column_style)
1003 minetest.set_node(cpos, {name=nn, param2=p2})
1004 if nn == "default:chest" then
1005 table.insert(chests, cpos)
1010 elseif room.style == "stacked" then
1011 local layout_list = room.layout
1012 local layout
1013 local layout_offset = room.layout_offset
1014 local layout_height = room.layout_height
1015 if not layout_offset then
1016 layout_offset = 0
1018 if not layout_height then
1019 layout_height = 5
1021 for iy=0,layout_height-1,1 do
1022 layout = nil
1023 if layout_list[layout_height-iy] then
1024 layout = rotate_layout(layout_list[layout_height-iy], ROOM_WIDTH, rotations)
1026 for ix=0,8,1 do
1027 for iz=0,8,1 do
1028 local n_str
1029 if layout then
1030 n_str = layout[ix*9+iz+1]
1031 else
1032 n_str = " "
1034 local p2 = 0
1035 if n_str == "<" then
1036 p2 = 0
1037 elseif n_str == ">" then
1038 p2 = 2
1039 elseif n_str == "^" then
1040 p2 = 1
1041 elseif n_str == "v" then
1042 p2 = 3
1044 local cpos = {x=hole.x+ix,y=hole.y-iy+layout_offset,z=hole.z+iz}
1045 local nn = code_table[n_str]
1046 minetest.set_node(cpos, {name=nn, param2=p2})
1047 if nn == "default:chest" then
1048 table.insert(chests, cpos)
1053 else
1054 minetest.log("error", "Invalid pyramid room style! room type ID="..r)
1056 local sanded = room.flood_sand ~= false and stype ~= "desert_stone" and math.random(1,8) == 1
1057 if #chests > 0 then
1058 -- Make at least 8 attempts to fill chests
1059 local filled = 0
1060 local chests_with_treasure = 0
1061 while filled < 8 do
1062 for c=1, #chests do
1063 local has_treasure = tsm_pyramids.fill_chest(chests[c], stype, sanded, 30)
1064 if has_treasure then
1065 chests_with_treasure = chests_with_treasure + 1
1067 filled = filled + 1
1070 -- If no chests were filled with treasure so far, fill a random chest guaranteed
1071 if chests_with_treasure == 0 then
1072 tsm_pyramids.fill_chest(chests[math.random(1, #chests)], stype, sanded, 100)
1075 if room.traps and math.random(1,4) == 1 then
1076 tsm_pyramids.make_traps(pos, stype, rotations, layout)
1078 if sanded then
1079 tsm_pyramids.flood_sand(pos, stype)
1081 return true, nil, sanded
1084 local shuffle_traps = function(layout_traps, layout_room, chance)
1085 for a=1, #layout_traps do
1086 -- Delete trap if this space of the room is occupied
1087 if layout_room[a] ~= " " then
1088 layout_traps[a] = "S"
1089 -- Randomly turn tile into a trap, or not
1090 elseif layout_traps[a] == "?" then
1091 -- percentage for a trap
1092 if math.random(1,100) <= chance then
1093 layout_traps[a] = "~"
1094 else
1095 layout_traps[a] = "S"
1101 function tsm_pyramids.make_traps(pos, stype, rotations, layout_room)
1102 local code_table = code_sandstone
1103 if stype == "desert_sandstone" then
1104 code_table = code_desert_sandstone
1105 elseif stype == "desert_stone" then
1106 code_table = code_desert_stone
1108 local layout_traps = table.copy(layout_traps_template)
1109 layout_traps = rotate_layout(layout_traps, ROOM_WIDTH, rotations)
1110 shuffle_traps(layout_traps, layout_room, math.random(10,100))
1111 -- Depth is total depth of trap area:
1112 -- * top layer with trap stones
1113 -- * followed by air layers
1114 -- * followed by 2 layers of lava
1115 -- * and 2 layers of sandstone/brick at the bottom (to prevent lava escaping)
1116 -- The depth of air between trap stones and lava layer is <depth> - 4
1117 local deep_trap = math.random(1,2) == 1
1118 local trap_node
1119 local depth
1120 if deep_trap then
1121 trap_node = " "
1122 depth = 14
1123 else
1124 trap_node = "~"
1125 depth = 7
1127 local wmin, wmax = -1,9
1128 local hole = {x=pos.x+7,y=pos.y, z=pos.z+7}
1129 for iy=0,depth,1 do
1130 for ix=wmin,wmax,1 do
1131 for iz=wmin,wmax,1 do
1132 local n_str
1133 if ix == wmin or ix == wmax or iz == wmin or iz == wmax then
1134 -- Walls around room
1135 if iy == depth then
1136 n_str = code_table["s"]
1137 else
1138 n_str = code_table["S"]
1140 minetest.set_node({x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}, {name=n_str})
1141 else
1142 n_str = layout_traps[ix*9+iz+1]
1143 minetest.set_node({x=hole.x+ix,y=hole.y-iy,z=hole.z+iz}, {name=replace2(n_str, iy, depth, code_table, trap_node)})
1150 function tsm_pyramids.flood_sand(pos, stype)
1151 local set_to_sand = {}
1152 local nn = "default:sand"
1153 if stype == "desert_sandstone" or stype == "desert_stone" then
1154 nn = "default:desert_sand"
1156 local hole = {x=pos.x+7,y=pos.y+1, z=pos.z+7}
1157 local maxh = math.random(1,4)
1158 local chance = math.random(1,7)
1159 for ix=0,8,1 do
1160 for iz=0,8,1 do
1161 if math.random(1,chance) == 1 then
1162 local h = math.random(1,maxh)
1163 for iy=0,h,1 do
1164 local p = {x=hole.x+ix,y=hole.y+iy,z=hole.z+iz}
1165 if minetest.get_node(p).name == "air" then
1166 table.insert(set_to_sand, p)
1172 minetest.bulk_set_node(set_to_sand, {name=nn})