Skip to content

Commit 01ad090

Browse files
LymkwiEkdohibs
authored andcommittedJun 6, 2015
Improved flowers' registration system - Specific nodeboxes, - Color groups - All datas were put into a table then unpacked for add_simple_flower
1 parent 638add6 commit 01ad090

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed
 

‎mods/flowers/init.lua

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

4+
-- Namespace for functions
5+
flowers = {}
6+
47
-- Map Generation
58
dofile(minetest.get_modpath("flowers").."/mapgen.lua")
69

@@ -13,13 +16,20 @@ minetest.register_alias("flowers:flower_tulip", "flowers:tulip")
1316
minetest.register_alias("flowers:flower_viola", "flowers:viola")
1417

1518
-- Flower registration function
16-
local function add_simple_flower(name, desc, image, f_groups)
19+
local function add_simple_flower(name, desc, box, f_groups)
20+
-- Common flowers' groups
21+
f_groups.snappy = 3
22+
f_groups.flammable = 2
23+
f_groups.flower = 1
24+
f_groups.flora = 1
25+
f_groups.attached_node = 1
26+
1727
minetest.register_node("flowers:"..name.."", {
1828
description = desc,
1929
drawtype = "plantlike",
20-
tiles = { image..".png" },
21-
inventory_image = image..".png",
22-
wield_image = image..".png",
30+
tiles = { "flowers_" .. name .. ".png" },
31+
inventory_image = "flowers_" .. name .. ".png",
32+
wield_image = "flowers_" .. name .. ".png",
2333
sunlight_propagates = true,
2434
paramtype = "light",
2535
walkable = false,
@@ -28,19 +38,24 @@ local function add_simple_flower(name, desc, image, f_groups)
2838
sounds = default.node_sound_leaves_defaults(),
2939
selection_box = {
3040
type = "fixed",
31-
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
32-
},
41+
fixed = box
42+
}
3343
})
3444
end
3545

3646
-- 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})
47+
flowers.datas = {
48+
{"dandelion_yellow", "Yellow Dandelion", { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 }, {color_yellow=1}},
49+
{"geranium", "Blue Geranium", { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 }, {color_blue=1}},
50+
{"rose", "Rose", { -0.15, -0.5, -0.15, 0.15, 0.3, 0.15 }, {color_red=1}},
51+
{"tulip", "Orange Tulip", { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 }, {color_orange=1}},
52+
{"dandelion_white", "White dandelion", { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 }, {color_white=1}},
53+
{"viola", "Viola", { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 }, {color_violet=1}}
54+
}
4355

56+
for _,item in pairs(flowers.datas) do
57+
add_simple_flower(unpack(item))
58+
end
4459

4560
minetest.register_abm({
4661
nodenames = {"group:flora"},

0 commit comments

Comments
 (0)