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 changed files with 27 additions and 108 deletions

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)
drawtype = "plantlike", minetest.register_node("flowers:"..name.."", {
tiles = { "flowers_dandelion_white.png" }, description = desc,
inventory_image = "flowers_dandelion_white.png", drawtype = "plantlike",
wield_image = "flowers_dandelion_white.png", tiles = { image..".png" },
sunlight_propagates = true, inventory_image = image..".png",
paramtype = "light", wield_image = image..".png",
walkable = false, sunlight_propagates = true,
buildable_to = true, paramtype = "light",
groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1}, walkable = false,
sounds = default.node_sound_leaves_defaults(), stack_max = 99,
selection_box = { groups = f_groups,
type = "fixed", sounds = default.node_sound_leaves_defaults(),
fixed = { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 }, selection_box = {
}, type = "fixed",
}) fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
},
})
end
minetest.register_node("flowers:dandelion_yellow", { -- Registrations using the function above
description = "Yellow Dandelion", 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_dandelion_yellow.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_dandelion_yellow.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_dandelion_yellow.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_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 },
},
})
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({ minetest.register_abm({
nodenames = {"group:flora"}, nodenames = {"group:flora"},