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

@ -1,9 +1,6 @@
-- Minetest 0.4 mod: default
-- See README.txt for licensing and other information.
-- Namespace for functions
flowers = {}
-- Map Generation
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_viola", "flowers:viola")
minetest.register_node("flowers:dandelion_white", {
description = "White Dandelion",
drawtype = "plantlike",
tiles = { "flowers_dandelion_white.png" },
inventory_image = "flowers_dandelion_white.png",
wield_image = "flowers_dandelion_white.png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
buildable_to = true,
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1},
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 },
},
})
-- Flower registration function
local function add_simple_flower(name, desc, image, f_groups)
minetest.register_node("flowers:"..name.."", {
description = desc,
drawtype = "plantlike",
tiles = { image..".png" },
inventory_image = image..".png",
wield_image = image..".png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
stack_max = 99,
groups = f_groups,
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
end
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(),
selection_box = {
type = "fixed",
fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
-- Registrations using the function above
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})
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})
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})
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})
add_simple_flower("dandelion_white", "White dandelion", "flowers_dandelion_white",{snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1})
add_simple_flower("viola", "Viola", "flowers_viola", {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_violet=1})
minetest.register_node("flowers:geranium", {
description = "Blue Geranium",
drawtype = "plantlike",
tiles = { "flowers_geranium.png" },
inventory_image = "flowers_geranium.png",
wield_image = "flowers_geranium.png",
sunlight_propagates = true,
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({
nodenames = {"group:flora"},