Fix global variable warnings; push to 0.4.2
[minetest_pyramids.git] / room.lua
bloba217ddd1e130e44a4248aa20797d8fae535b77e9
1 local room = {"a","a","a","a","a","a","a","a","a",
2 "a","c","a","c","a","c","a","c","a",
3 "a","s","a","s","a","s","a","s","a",
4 "a","a","a","a","a","a","a","a","a",
5 "a","a","a","a","a","a","a","a","a",
6 "a","a","a","a","a","a","a","a","a",
7 "a","s","a","s","a","s","a","s","a",
8 "a","c","a","c","a","c","a","c","a",
9 "a","a","a","a","a","a","a","a","a"}
11 local trap = {"b","b","b","b","b","b","b","b","b",
12 "l","b","l","b","l","b","l","b","b",
13 "l","b","l","b","l","b","l","b","b",
14 "l","b","l","l","l","b","l","l","b",
15 "l","l","b","l","b","l","l","b","b",
16 "l","b","l","l","l","l","l","l","b",
17 "l","b","l","b","l","b","l","b","b",
18 "l","b","l","b","l","b","l","b","b",
19 "b","b","b","b","b","b","b","b","b"}
21 local code = {}
22 code["s"] = "sandstone"
23 code["eye"] = "deco_stone1"
24 code["men"] = "deco_stone2"
25 code["sun"] = "deco_stone3"
26 code["c"] = "chest"
27 code["b"] = "sandstonebrick"
28 code["a"] = "air"
29 code["l"] = "lava_source"
30 code["t"] = "trap"
32 local function replace(str,iy)
33 local out = "default:"
34 if iy < 4 and str == "c" then str = "a" end
35 if iy == 0 and str == "s" then out = "pyramids:" str = "sun" end
36 if iy == 3 and str == "s" then out = "pyramids:" str = "men" end
37 if str == "a" then out = "" end
38 return out..code[str]
39 end
41 local function replace2(str,iy)
42 local out = "default:"
43 if iy == 0 and str == "l" then out = "pyramids:" str = "t"
44 elseif iy < 3 and str == "l" then str = "a" end
46 if str == "a" then out = "" end
47 return out..code[str]
48 end
50 function pyramids.make_room(pos)
51 local loch = {x=pos.x+7,y=pos.y+5, z=pos.z+7}
52 for iy=0,4,1 do
53 for ix=0,8,1 do
54 for iz=0,8,1 do
55 local n_str = room[tonumber(ix*9+iz+1)]
56 local p2 = 0
57 if n_str == "c" then
58 if ix < 3 then p2 = 1 else p2 = 3 end
59 pyramids.fill_chest({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz})
60 end
61 minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace(n_str,iy), param2=p2})
62 end
63 end
64 end
65 end
67 function pyramids.make_traps(pos)
68 local loch = {x=pos.x+7,y=pos.y, z=pos.z+7}
69 for iy=0,4,1 do
70 for ix=0,8,1 do
71 for iz=0,8,1 do
72 local n_str = trap[tonumber(ix*9+iz+1)]
73 local p2 = 0
74 minetest.set_node({x=loch.x+ix,y=loch.y-iy,z=loch.z+iz}, {name=replace2(n_str,iy), param2=p2})
75 end
76 end
77 end
78 end