Skip to content

Commit 638add6

Browse files
OmbridrideEkdohibs
Ombridride
authored andcommittedJun 6, 2015
Simplified flowers' registration - Created a new local function to register flowers
1 parent 750f957 commit 638add6

File tree

1 file changed

+27
-108
lines changed

1 file changed

+27
-108
lines changed
 

‎mods/flowers/init.lua

+27-108
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
-- Minetest 0.4 mod: default
22
-- See README.txt for licensing and other information.
33

4-
-- Namespace for functions
5-
flowers = {}
6-
74
-- Map Generation
85
dofile(minetest.get_modpath("flowers").."/mapgen.lua")
96

@@ -15,113 +12,35 @@ minetest.register_alias("flowers:flower_rose", "flowers:rose")
1512
minetest.register_alias("flowers:flower_tulip", "flowers:tulip")
1613
minetest.register_alias("flowers:flower_viola", "flowers:viola")
1714

18-
minetest.register_node("flowers:dandelion_white", {
19-
description = "White Dandelion",
20-
drawtype = "plantlike",
21-
tiles = { "flowers_dandelion_white.png" },
22-
inventory_image = "flowers_dandelion_white.png",
23-
wield_image = "flowers_dandelion_white.png",
24-
sunlight_propagates = true,
25-
paramtype = "light",
26-
walkable = false,
27-
buildable_to = true,
28-
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1},
29-
sounds = default.node_sound_leaves_defaults(),
30-
selection_box = {
31-
type = "fixed",
32-
fixed = { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 },
33-
},
34-
})
35-
36-
minetest.register_node("flowers:dandelion_yellow", {
37-
description = "Yellow Dandelion",
38-
drawtype = "plantlike",
39-
tiles = { "flowers_dandelion_yellow.png" },
40-
inventory_image = "flowers_dandelion_yellow.png",
41-
wield_image = "flowers_dandelion_yellow.png",
42-
sunlight_propagates = true,
43-
paramtype = "light",
44-
walkable = false,
45-
buildable_to = true,
46-
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_yellow=1},
47-
sounds = default.node_sound_leaves_defaults(),
48-
selection_box = {
49-
type = "fixed",
50-
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
51-
},
52-
})
53-
54-
minetest.register_node("flowers:geranium", {
55-
description = "Blue Geranium",
56-
drawtype = "plantlike",
57-
tiles = { "flowers_geranium.png" },
58-
inventory_image = "flowers_geranium.png",
59-
wield_image = "flowers_geranium.png",
60-
sunlight_propagates = true,
61-
paramtype = "light",
62-
walkable = false,
63-
buildable_to = true,
64-
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_blue=1},
65-
sounds = default.node_sound_leaves_defaults(),
66-
selection_box = {
67-
type = "fixed",
68-
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
69-
},
70-
})
15+
-- Flower registration function
16+
local function add_simple_flower(name, desc, image, f_groups)
17+
minetest.register_node("flowers:"..name.."", {
18+
description = desc,
19+
drawtype = "plantlike",
20+
tiles = { image..".png" },
21+
inventory_image = image..".png",
22+
wield_image = image..".png",
23+
sunlight_propagates = true,
24+
paramtype = "light",
25+
walkable = false,
26+
stack_max = 99,
27+
groups = f_groups,
28+
sounds = default.node_sound_leaves_defaults(),
29+
selection_box = {
30+
type = "fixed",
31+
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
32+
},
33+
})
34+
end
7135

72-
minetest.register_node("flowers:rose", {
73-
description = "Rose",
74-
drawtype = "plantlike",
75-
tiles = { "flowers_rose.png" },
76-
inventory_image = "flowers_rose.png",
77-
wield_image = "flowers_rose.png",
78-
sunlight_propagates = true,
79-
paramtype = "light",
80-
walkable = false,
81-
buildable_to = true,
82-
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_red=1},
83-
sounds = default.node_sound_leaves_defaults(),
84-
selection_box = {
85-
type = "fixed",
86-
fixed = { -0.15, -0.5, -0.15, 0.15, 0.3, 0.15 },
87-
},
88-
})
36+
-- Registrations using the function above
37+
add_simple_flower("dandelion_yellow", "Yellow Dandelion", "flowers_dandelion_yellow", {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,dig_by_water=1,color_yellow=1})
38+
add_simple_flower("geranium", "Blue Geranium", "flowers_geranium", {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,dig_by_water=1,color_blue=1})
39+
add_simple_flower("rose", "Rose", "flowers_rose", {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,dig_by_water=1,color_red=1})
40+
add_simple_flower("tulip", "Orange Tulip", "flowers_tulip", {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,dig_by_water=1,color_orange=1})
41+
add_simple_flower("dandelion_white", "White dandelion", "flowers_dandelion_white",{snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1})
42+
add_simple_flower("viola", "Viola", "flowers_viola", {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_violet=1})
8943

90-
minetest.register_node("flowers:tulip", {
91-
description = "Tulip",
92-
drawtype = "plantlike",
93-
tiles = { "flowers_tulip.png" },
94-
inventory_image = "flowers_tulip.png",
95-
wield_image = "flowers_tulip.png",
96-
sunlight_propagates = true,
97-
paramtype = "light",
98-
walkable = false,
99-
buildable_to = true,
100-
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_orange=1},
101-
sounds = default.node_sound_leaves_defaults(),
102-
selection_box = {
103-
type = "fixed",
104-
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
105-
},
106-
})
107-
108-
minetest.register_node("flowers:viola", {
109-
description = "Viola",
110-
drawtype = "plantlike",
111-
tiles = { "flowers_viola.png" },
112-
inventory_image = "flowers_viola.png",
113-
wield_image = "flowers_viola.png",
114-
sunlight_propagates = true,
115-
paramtype = "light",
116-
walkable = false,
117-
buildable_to = true,
118-
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_violet=1},
119-
sounds = default.node_sound_leaves_defaults(),
120-
selection_box = {
121-
type = "fixed",
122-
fixed = { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 },
123-
},
124-
})
12544

12645
minetest.register_abm({
12746
nodenames = {"group:flora"},

0 commit comments

Comments
 (0)
Please sign in to comment.