Fix deco node names
[minetest_pyramids/tsm_pyramids.git] / nodes.lua
blob72935a97f6424d139f2bfcd8971ec47775433e7f
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 for i, obj in pairs(objs) do
45 if obj:is_player() then
46 local n = minetest.get_node(pos)
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 minetest.set_node(pos, {name="tsm_pyramids:trap_2"})
50 minetest.check_for_falling(pos)
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 = "",