Skip to content

Commit

Permalink
Improved flowers' registration system - Specific nodeboxes, - Color g…
Browse files Browse the repository at this point in the history
…roups - All datas were put into a table then unpacked for add_simple_flower
  • Loading branch information
Lymkwi authored and Ekdohibs committed Jun 6, 2015
1 parent 638add6 commit 01ad090
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions mods/flowers/init.lua
@@ -1,6 +1,9 @@
-- 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")

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

-- Flower registration function
local function add_simple_flower(name, desc, image, f_groups)
local function add_simple_flower(name, desc, box, f_groups)
-- Common flowers' groups
f_groups.snappy = 3
f_groups.flammable = 2
f_groups.flower = 1
f_groups.flora = 1
f_groups.attached_node = 1

minetest.register_node("flowers:"..name.."", {
description = desc,
drawtype = "plantlike",
tiles = { image..".png" },
inventory_image = image..".png",
wield_image = image..".png",
tiles = { "flowers_" .. name .. ".png" },
inventory_image = "flowers_" .. name .. ".png",
wield_image = "flowers_" .. name .. ".png",
sunlight_propagates = true,
paramtype = "light",
walkable = false,
Expand All @@ -28,19 +38,24 @@ local function add_simple_flower(name, desc, image, 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 },
},
fixed = box
}
})
end

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

for _,item in pairs(flowers.datas) do
add_simple_flower(unpack(item))
end

minetest.register_abm({
nodenames = {"group:flora"},
Expand Down

0 comments on commit 01ad090

Please sign in to comment.