Flowers: Make mushrooms farmable using spores

This commit is contained in:
paramat 2015-08-01 02:13:14 +01:00
parent 84de5f0f40
commit 8d1eef025d
4 changed files with 87 additions and 23 deletions

View File

@ -17,3 +17,6 @@ WTFPL
Gambit (WTFPL): Gambit (WTFPL):
flowers_mushroom_*.png flowers_mushroom_*.png
DanDuncombe (WTFPL):
flowers_spores_*.png

View File

@ -4,9 +4,11 @@
-- Namespace for functions -- Namespace for functions
flowers = {} flowers = {}
-- Map Generation -- Map Generation
dofile(minetest.get_modpath("flowers") .. "/mapgen.lua") dofile(minetest.get_modpath("flowers") .. "/mapgen.lua")
-- Aliases for original flowers mod -- Aliases for original flowers mod
minetest.register_alias("flowers:flower_dandelion_white", "flowers:dandelion_white") minetest.register_alias("flowers:flower_dandelion_white", "flowers:dandelion_white")
minetest.register_alias("flowers:flower_dandelion_yellow", "flowers:dandelion_yellow") minetest.register_alias("flowers:flower_dandelion_yellow", "flowers:dandelion_yellow")
@ -15,7 +17,9 @@ 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")
-- Flower registration function
-- Flower registration
local function add_simple_flower(name, desc, box, f_groups) local function add_simple_flower(name, desc, box, f_groups)
-- Common flowers' groups -- Common flowers' groups
f_groups.snappy = 3 f_groups.snappy = 3
@ -24,7 +28,7 @@ local function add_simple_flower(name, desc, box, f_groups)
f_groups.flora = 1 f_groups.flora = 1
f_groups.attached_node = 1 f_groups.attached_node = 1
minetest.register_node("flowers:"..name.."", { minetest.register_node("flowers:" .. name, {
description = desc, description = desc,
drawtype = "plantlike", drawtype = "plantlike",
tiles = {"flowers_" .. name .. ".png"}, tiles = {"flowers_" .. name .. ".png"},
@ -43,26 +47,32 @@ local function add_simple_flower(name, desc, box, f_groups)
}) })
end end
-- Registrations using the function above
flowers.datas = { 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}}, {"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}}, {"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}}, {"dandelion_yellow", "Yellow Dandelion", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_yellow = 1}},
{"viola", "Viola", { -0.5, -0.5, -0.5, 0.5, -0.2, 0.5 }, {color_violet=1}} {"geranium", "Blue Geranium", {-0.15, -0.5, -0.15, 0.15, 0.2, 0.15}, {color_blue = 1}},
{"viola", "Viola", {-0.5, -0.5, -0.5, 0.5, -0.2, 0.5}, {color_violet = 1}},
{"dandelion_white", "White dandelion", {-0.5, -0.5, -0.5, 0.5, -0.2, 0.5}, {color_white = 1}}
} }
for _,item in pairs(flowers.datas) do for _,item in pairs(flowers.datas) do
add_simple_flower(unpack(item)) add_simple_flower(unpack(item))
end end
-- Mushrooms
local mushrooms_datas = { local mushrooms_datas = {
{"brown", 2}, {"red", -6} {"brown", 2},
{"red", -6}
} }
for _, m in pairs(mushrooms_datas) do for _, m in pairs(mushrooms_datas) do
local name, nut = m[1], m[2] local name, nut = m[1], m[2]
-- Register mushrooms
minetest.register_node("flowers:mushroom_" .. name, { minetest.register_node("flowers:mushroom_" .. name, {
description = string.sub(string.upper(name), 0, 1) .. description = string.sub(string.upper(name), 0, 1) ..
string.sub(name, 2) .. " Mushroom", string.sub(name, 2) .. " Mushroom",
@ -75,6 +85,14 @@ for _, m in pairs(mushrooms_datas) do
walkable = false, walkable = false,
buildable_to = true, buildable_to = true,
groups = {snappy = 3, flammable = 3, attached_node = 1}, groups = {snappy = 3, flammable = 3, attached_node = 1},
drop = {
items = {
{items = {"flowers:spores_" .. name}, rarity = 2,},
{items = {"flowers:spores_" .. name}, rarity = 2,},
{items = {"flowers:spores_" .. name}, rarity = 2,},
{items = {"flowers:mushroom_" .. name},},
},
},
sounds = default.node_sound_leaves_defaults(), sounds = default.node_sound_leaves_defaults(),
on_use = minetest.item_eat(nut), on_use = minetest.item_eat(nut),
selection_box = { selection_box = {
@ -82,7 +100,50 @@ for _, m in pairs(mushrooms_datas) do
fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3} fixed = {-0.3, -0.5, -0.3, 0.3, 0, 0.3}
} }
}) })
-- Register spores
minetest.register_node("flowers:spores_" .. name, {
description = string.sub(string.upper(name), 0, 1) ..
string.sub(name, 2) .. " Mushroom Spores",
drawtype = "signlike",
tiles = {"flowers_spores_" .. name .. ".png"},
inventory_image = "flowers_spores_" .. name .. ".png",
wield_image = "flowers_spores_" .. name .. ".png",
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
walkable = false,
buildable_to = true,
selection_box = {
type = "wallmounted",
},
groups = {dig_immediate = 3, attached_node = 1},
})
-- Register growth ABMs
minetest.register_abm({
nodenames = {"flowers:spores_" .. name},
interval = 14,
chance = 25,
action = function(pos, node)
local node_under = minetest.get_node_or_nil({x = pos.x,
y = pos.y - 1, z = pos.z})
if not node_under then
return
end end
if minetest.get_item_group(node_under.name, "soil") ~= 0 and
minetest.get_node_light(pos, nil) <= 13 then
minetest.set_node({x = pos.x, y = pos.y, z = pos.z},
{name = "flowers:mushroom_" .. name})
end
end
})
end
-- Flower spread
minetest.register_abm({ minetest.register_abm({
nodenames = {"group:flora"}, nodenames = {"group:flora"},

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B