Add room type argument in spawnpyramid command
[minetest_pyramids/tsm_pyramids.git] / nodes.lua
blobbc6b10b3745a7688f69661db028afdbfba698e1f
1 local S = minetest.get_translator("tsm_pyramids")
3 local img = {
4 "eye", "men", "sun",
5 "ankh", "scarab", "cactus"
7 local desc = {
8 S("Sandstone with Eye Engraving"), S("Sandstone with Man Engraving"), S("Sandstone with Sun Engraving"),
9 S("Desert Sandstone with Ankh Engraving"), S("Desert Sandstone with Scarab Engraving"), S("Desert Sandstone with Cactus Engraving")
12 local decodesc = ""
13 if minetest.get_modpath("doc_items") then
14 decodesc = doc.sub.items.temp.deco
15 end
17 for i=1, #img do
18 local sandstone_img, basenode
19 if i > 3 then
20 sandstone_img = "default_desert_sandstone.png"
21 basenode = "default:desert_sandstone"
22 else
23 sandstone_img = "default_sandstone.png"
24 basenode = "default:sandstone"
25 end
26 minetest.register_node("tsm_pyramids:deco_stone"..i, {
27 description = desc[i],
28 _doc_items_longdesc = decodesc,
29 is_ground_content = false,
30 tiles = {sandstone_img, sandstone_img, sandstone_img.."^tsm_pyramids_"..img[i]..".png"},
31 groups = minetest.registered_nodes[basenode].groups,
32 sounds = minetest.registered_nodes[basenode].sounds,
34 end
36 local trap_on_timer = function(pos, elapsed)
37 local objs = minetest.get_objects_inside_radius(pos, 2)
38 local n = minetest.get_node(pos)
39 for i, obj in pairs(objs) do
40 if obj:is_player() then
41 if n and n.name then
42 if minetest.registered_nodes[n.name]._tsm_pyramids_crack and minetest.registered_nodes[n.name]._tsm_pyramids_crack < 2 then
43 if n.name == "tsm_pyramids:trap" then
44 minetest.set_node(pos, {name="tsm_pyramids:trap_2"})
45 minetest.check_for_falling(pos)
46 elseif n.name == "tsm_pyramids:desert_trap" then
47 minetest.set_node(pos, {name="tsm_pyramids:desert_trap_2"})
48 minetest.check_for_falling(pos)
49 end
50 return true
51 end
52 end
53 end
54 end
55 return true
56 end
58 minetest.register_node("tsm_pyramids:trap", {
59 description = S("Cracked Sandstone Brick"),
60 _doc_items_longdesc = S("This brick is old, porous and unstable and is barely able to hold itself. One should be careful not to disturb it."),
61 tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png"},
62 is_ground_content = false,
63 groups = {crumbly=3,cracky=3},
64 sounds = default.node_sound_stone_defaults(),
65 on_construct = function(pos)
66 minetest.get_node_timer(pos):start(0.1)
67 end,
68 _tsm_pyramids_crack = 1,
69 on_timer = trap_on_timer,
70 drop = "",
73 minetest.register_node("tsm_pyramids:trap_2", {
74 description = S("Falling Cracked Sandstone Brick"),
75 _doc_items_longdesc = S("This old porous brick falls under its own weight."),
76 tiles = {"default_sandstone_brick.png^tsm_pyramids_crack2.png"},
77 is_ground_content = false,
78 groups = {crumbly=3,cracky=3,falling_node=1,not_in_creative_inventory=1},
79 sounds = default.node_sound_stone_defaults(),
80 drop = "",
83 minetest.register_node("tsm_pyramids:desert_trap", {
84 description = S("Cracked Desert Sandstone Brick"),
85 _doc_items_longdesc = S("This brick is old, porous and unstable and is barely able to hold itself. One should be careful not to disturb it."),
86 tiles = {"default_desert_sandstone_brick.png^tsm_pyramids_crack.png"},
87 is_ground_content = false,
88 groups = {crumbly=3,cracky=3},
89 sounds = default.node_sound_stone_defaults(),
90 on_construct = function(pos)
91 minetest.get_node_timer(pos):start(0.1)
92 end,
93 _tsm_pyramids_crack = 1,
94 on_timer = trap_on_timer,
95 drop = "",
98 minetest.register_node("tsm_pyramids:desert_trap_2", {
99 description = S("Falling Cracked Desert Sandstone Brick"),
100 _doc_items_longdesc = S("This old porous brick falls under its own weight."),
101 tiles = {"default_desert_sandstone_brick.png^tsm_pyramids_crack2.png"},
102 is_ground_content = false,
103 groups = {crumbly=3,cracky=3,falling_node=1,not_in_creative_inventory=1},
104 sounds = default.node_sound_stone_defaults(),
105 drop = "",