Fix wield image of torchlike fruit
[minetest_hades/hades_revisited.git] / mods / hades_trees / api.lua
blob2004753b6c024dc5187aab81bfcbaff6de923a63
1 local S = minetest.get_translator("hades_trees")
3 hades_trees.register_trunk = function(id, def)
4 minetest.register_node("hades_trees:"..id, {
5 description = def.description,
6 tiles = def.tiles,
7 paramtype = "light",
8 drawtype = "nodebox",
9 node_box = {
10 type = "fixed",
11 fixed = {
12 {-0.5,-0.5,-3/16, 0.5,0.5,3/16},
13 {-7/16,-0.5,-5/16, 7/16,0.5,5/16},
14 {-6/16,-0.5,-6/16, 6/16,0.5,6/16},
15 {-5/16,-0.5,-7/16, 5/16,0.5,7/16},
16 {-3/16,-0.5,-0.5, 3/16,0.5,0.5},
19 is_ground_content = false,
20 groups = {tree=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
21 sounds = hades_sounds.node_sound_wood_defaults(),
23 end
25 hades_trees.register_bark = function(id, def)
26 minetest.register_node("hades_trees:"..id, {
27 description = def.description,
28 paramtype2 = "facedir",
29 tiles = { def.image },
30 is_ground_content = false,
31 groups = { bark=1, choppy = 3, oddly_breakable_by_hand = 1, flammable = 2 },
32 sounds = hades_sounds.node_sound_wood_defaults(),
34 end
36 hades_trees.register_sapling = function(id, def)
37 local tth
38 if def.growtype == "ash" then
39 tth = S("Needs Dirt, Fertile Sand or Volcanic Ash to grow, and light")
40 else
41 tth = S("Needs Dirt and light to grow")
42 end
43 minetest.register_node("hades_trees:"..id, {
44 description = def.description,
45 _tt_help = tth,
46 drawtype = "plantlike",
47 tiles = {def.image},
48 inventory_image = def.image,
49 wield_image = def.image,
50 paramtype = "light",
51 walkable = false,
52 is_ground_content = false,
53 floodable = true,
54 selection_box = {
55 type = "fixed",
56 fixed = def.selbox,
58 groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1, sapling=1},
59 sounds = hades_sounds.node_sound_leaves_defaults(),
61 end
63 hades_trees.register_leaves = function(id, def)
64 local drop = {
65 max_items = 1,
66 items = {
68 -- player will get sapling with chance of (1/def.drop_rarity)
69 items = {def.drop_item},
70 rarity = def.drop_rarity,
73 -- player will get leaves only if they get no def.drop_item,
74 -- this is because max_items is 1
75 items = {"hades_trees:"..id},
79 minetest.register_node("hades_trees:"..id, {
80 description = def.description,
81 drawtype = "allfaces_optional",
82 tiles = {def.image},
83 paramtype = "light",
84 waving = 1,
85 is_ground_content = false,
86 place_param2 = 1,
87 groups = {snappy=3, leafdecay=3, flammable=2, leaves=1, ash_fertilizer=def.ash_fertilizer, porous=1},
88 drop = drop,
89 sounds = hades_sounds.node_sound_leaves_defaults(),
91 end
93 hades_trees.register_fruit = function(id, def)
94 local sat = def.satiation
95 local on_use, food
96 if def.satiation then
97 food = 2
98 on_use = minetest.item_eat(sat)
99 end
100 local groups = {dig_immediate=3,flammable=2,leafdecay=3,leafdecay_drop=1,food=food,eatable=sat}
101 if def.groups then
102 for k,v in pairs(def.groups) do
103 if v == 0 then
104 v = nil
106 groups[k] = v
109 minetest.register_node("hades_trees:"..id, {
110 description = def.description,
111 drawtype = def.drawtype,
112 tiles = {def.image},
113 inventory_image = def.image,
114 wield_image = def.image,
115 paramtype = "light",
116 sunlight_propagates = true,
117 walkable = false,
118 is_ground_content = false,
119 floodable = true,
120 selection_box = {
121 type = "fixed",
122 fixed = def.selbox,
124 groups = groups,
125 on_use = on_use,
126 sounds = hades_sounds.node_sound_leaves_defaults(),
127 place_param2 = 1,