Add desert sandstone trap
[minetest_pyramids/tsm_pyramids.git] / nodes.lua
blobc40486297387314e1c7deb48311b541c26a9c8dd
1 -- Boilerplate to support localized strings if intllib mod is installed.
2 local S
3 if minetest.get_modpath("intllib") then
4 S = intllib.Getter()
5 else
6 S = function(s) return s end
7 end
9 local img = {
10 "eye", "men", "sun",
11 "ankh", "scarab", "cactus"
13 local desc = {
14 S("Sandstone with Eye Engraving"), S("Sandstone with Man Engraving"), S("Sandstone with Sun Engraving"),
15 S("Desert Sandstone with Ankh Engraving"), S("Desert Sandstone with Scarab Engraving"), S("Desert Sandstone with Cactus Engraving")
18 local decodesc = ""
19 if minetest.get_modpath("doc_items") then
20 decodesc = doc.sub.items.temp.deco
21 end
23 for i=1, #img do
24 local sandstone_img, basenode
25 if i > 3 then
26 sandstone_img = "default_desert_sandstone.png"
27 basenode = "default:desert_sandstone"
28 else
29 sandstone_img = "default_sandstone.png"
30 basenode = "default:sandstone"
31 end
32 minetest.register_node("tsm_pyramids:deco_stone"..i, {
33 description = desc[i],
34 _doc_items_longdesc = decodesc,
35 is_ground_content = false,
36 tiles = {sandstone_img, sandstone_img, sandstone_img.."^tsm_pyramids_"..img[i]..".png"},
37 groups = minetest.registered_nodes[basenode].groups,
38 sounds = minetest.registered_nodes[basenode].sounds,
40 end
42 local trap_on_timer = function(pos, elapsed)
43 local objs = minetest.get_objects_inside_radius(pos, 2)
44 local n = minetest.get_node(pos)
45 for i, obj in pairs(objs) do
46 if obj:is_player() then
47 if n and n.name then
48 if minetest.registered_nodes[n.name]._tsm_pyramids_crack and minetest.registered_nodes[n.name]._tsm_pyramids_crack < 2 then
49 if n.name == "tsm_pyramids:trap" then
50 minetest.set_node(pos, {name="tsm_pyramids:trap_2"})
51 minetest.check_for_falling(pos)
52 elseif n.name == "tsm_pyramids:desert_trap" then
53 minetest.set_node(pos, {name="tsm_pyramids:desert_trap_2"})
54 minetest.check_for_falling(pos)
55 end
56 return true
57 end
58 end
59 end
60 end
61 return true
62 end
64 minetest.register_node("tsm_pyramids:trap", {
65 description = S("Cracked Sandstone Brick"),
66 _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."),
67 tiles = {"default_sandstone_brick.png^tsm_pyramids_crack.png"},
68 is_ground_content = false,
69 groups = {crumbly=3,cracky=3},
70 sounds = default.node_sound_stone_defaults(),
71 on_construct = function(pos)
72 minetest.get_node_timer(pos):start(0.1)
73 end,
74 _tsm_pyramids_crack = 1,
75 on_timer = trap_on_timer,
76 drop = "",
79 minetest.register_node("tsm_pyramids:trap_2", {
80 description = S("Falling Cracked Sandstone Brick"),
81 _doc_items_longdesc = S("This old porous brick falls under its own weight."),
82 tiles = {"default_sandstone_brick.png^tsm_pyramids_crack2.png"},
83 is_ground_content = false,
84 groups = {crumbly=3,cracky=3,falling_node=1,not_in_creative_inventory=1},
85 sounds = default.node_sound_stone_defaults(),
86 drop = "",
89 minetest.register_node("tsm_pyramids:desert_trap", {
90 description = S("Cracked Desert Sandstone Brick"),
91 _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."),
92 tiles = {"default_desert_sandstone_brick.png^tsm_pyramids_crack.png"},
93 is_ground_content = false,
94 groups = {crumbly=3,cracky=3},
95 sounds = default.node_sound_stone_defaults(),
96 on_construct = function(pos)
97 minetest.get_node_timer(pos):start(0.1)
98 end,
99 _tsm_pyramids_crack = 1,
100 on_timer = trap_on_timer,
101 drop = "",
104 minetest.register_node("tsm_pyramids:desert_trap_2", {
105 description = S("Falling Cracked Desert Sandstone Brick"),
106 _doc_items_longdesc = S("This old porous brick falls under its own weight."),
107 tiles = {"default_desert_sandstone_brick.png^tsm_pyramids_crack2.png"},
108 is_ground_content = false,
109 groups = {crumbly=3,cracky=3,falling_node=1,not_in_creative_inventory=1},
110 sounds = default.node_sound_stone_defaults(),
111 drop = "",