Simplified flowers' registration - Created a new local function to register flowers

This commit is contained in:
Ombridride 2015-04-18 16:48:43 +02:00 committed by Novatux
parent 750f9575af
commit 638add603f

View File

@ -1,9 +1,6 @@
-- Minetest 0.4 mod: default -- Minetest 0.4 mod: default
-- See README.txt for licensing and other information. -- See README.txt for licensing and other information.
-- Namespace for functions
flowers = {}
-- Map Generation -- Map Generation
dofile(minetest.get_modpath("flowers").."/mapgen.lua") dofile(minetest.get_modpath("flowers").."/mapgen.lua")
@ -15,113 +12,35 @@ minetest.register_alias("flowers:flower_rose", "flowers:rose")
minetest.register_alias("flowers:flower_tulip", "flowers:tulip") minetest.register_alias("flowers:flower_tulip", "flowers:tulip")
minetest.register_alias("flowers:flower_viola", "flowers:viola") minetest.register_alias("flowers:flower_viola", "flowers:viola")
minetest.register_node("flowers:dandelion_white", { -- Flower registration function
description = "White Dandelion", local function add_simple_flower(name, desc, image, f_groups)
minetest.register_node("flowers:"..name.."", {
description = desc,
drawtype = "plantlike", drawtype = "plantlike",
tiles = { "flowers_dandelion_white.png" }, tiles = { image..".png" },
inventory_image = "flowers_dandelion_white.png", inventory_image = image..".png",
wield_image = "flowers_dandelion_white.png", wield_image = image..".png",
sunlight_propagates = true, sunlight_propagates = true,
paramtype = "light", paramtype = "light",
walkable = false, walkable = false,
buildable_to = true, stack_max = 99,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1}, groups = f_groups,
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 },
},
})
minetest.register_node("flowers:dandelion_yellow", {
description = "Yellow Dandelion",
drawtype = "plantlike",
tiles = { "flowers_dandelion_yellow.png" },
inventory_image = "flowers_dandelion_yellow.png",
wield_image = "flowers_dandelion_yellow.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_yellow=1},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 }, fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
}, },
}) })
end
minetest.register_node("flowers:geranium", { -- Registrations using the function above
description = "Blue Geranium", 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})
drawtype = "plantlike", 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})
tiles = { "flowers_geranium.png" }, 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})
inventory_image = "flowers_geranium.png", 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})
wield_image = "flowers_geranium.png", add_simple_flower("dandelion_white", "White dandelion", "flowers_dandelion_white",{snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1})
sunlight_propagates = true, add_simple_flower("viola", "Viola", "flowers_viola", {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_violet=1})
paramtype = "light",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_blue=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
minetest.register_node("flowers:rose", {
description = "Rose",
drawtype = "plantlike",
tiles = { "flowers_rose.png" },
inventory_image = "flowers_rose.png",
wield_image = "flowers_rose.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_red=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.3, 0.15 },
},
})
minetest.register_node("flowers:tulip", {
description = "Tulip",
drawtype = "plantlike",
tiles = { "flowers_tulip.png" },
inventory_image = "flowers_tulip.png",
wield_image = "flowers_tulip.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_orange=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
minetest.register_node("flowers:viola", {
description = "Viola",
drawtype = "plantlike",
tiles = { "flowers_viola.png" },
inventory_image = "flowers_viola.png",
wield_image = "flowers_viola.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_violet=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 },
},
})
minetest.register_abm({ minetest.register_abm({
nodenames = {"group:flora"}, nodenames = {"group:flora"},