From 8d1eef025d83e2b6d011ec630598463979a9f65a Mon Sep 17 00:00:00 2001 From: paramat Date: Sat, 1 Aug 2015 02:13:14 +0100 Subject: [PATCH] Flowers: Make mushrooms farmable using spores --- mods/flowers/README.txt | 3 + mods/flowers/init.lua | 107 ++++++++++++++---- .../flowers/textures/flowers_spores_brown.png | Bin 0 -> 94 bytes mods/flowers/textures/flowers_spores_red.png | Bin 0 -> 92 bytes 4 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 mods/flowers/textures/flowers_spores_brown.png create mode 100644 mods/flowers/textures/flowers_spores_red.png diff --git a/mods/flowers/README.txt b/mods/flowers/README.txt index df3c5f41..f83abcda 100644 --- a/mods/flowers/README.txt +++ b/mods/flowers/README.txt @@ -17,3 +17,6 @@ WTFPL Gambit (WTFPL): flowers_mushroom_*.png + +DanDuncombe (WTFPL): + flowers_spores_*.png diff --git a/mods/flowers/init.lua b/mods/flowers/init.lua index b24e323a..07507332 100644 --- a/mods/flowers/init.lua +++ b/mods/flowers/init.lua @@ -4,8 +4,10 @@ -- Namespace for functions flowers = {} + -- Map Generation -dofile(minetest.get_modpath("flowers").."/mapgen.lua") +dofile(minetest.get_modpath("flowers") .. "/mapgen.lua") + -- Aliases for original flowers mod minetest.register_alias("flowers:flower_dandelion_white", "flowers:dandelion_white") @@ -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_viola", "flowers:viola") --- Flower registration function + +-- Flower registration + local function add_simple_flower(name, desc, box, f_groups) -- Common flowers' groups f_groups.snappy = 3 @@ -24,10 +28,10 @@ local function add_simple_flower(name, desc, box, f_groups) f_groups.flora = 1 f_groups.attached_node = 1 - minetest.register_node("flowers:"..name.."", { + minetest.register_node("flowers:" .. name, { description = desc, drawtype = "plantlike", - tiles = { "flowers_" .. name .. ".png" }, + tiles = {"flowers_" .. name .. ".png"}, inventory_image = "flowers_" .. name .. ".png", wield_image = "flowers_" .. name .. ".png", sunlight_propagates = true, @@ -43,38 +47,52 @@ local function add_simple_flower(name, desc, box, f_groups) }) end --- Registrations using the function above 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}} + {"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_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}}, + {"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 add_simple_flower(unpack(item)) end + +-- Mushrooms + local mushrooms_datas = { - {"brown", 2}, {"red", -6} + {"brown", 2}, + {"red", -6} } for _, m in pairs(mushrooms_datas) do local name, nut = m[1], m[2] - minetest.register_node("flowers:mushroom_"..name, { - description = string.sub(string.upper(name), 0, 1).. - string.sub(name, 2).." Mushroom", - tiles = {"flowers_mushroom_"..name..".png"}, - inventory_image = "flowers_mushroom_"..name..".png", - wield_image = "flowers_mushroom_"..name..".png", + + -- Register mushrooms + + minetest.register_node("flowers:mushroom_" .. name, { + description = string.sub(string.upper(name), 0, 1) .. + string.sub(name, 2) .. " Mushroom", + tiles = {"flowers_mushroom_" .. name .. ".png"}, + inventory_image = "flowers_mushroom_" .. name .. ".png", + wield_image = "flowers_mushroom_" .. name .. ".png", drawtype = "plantlike", paramtype = "light", sunlight_propagates = true, walkable = false, 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(), on_use = minetest.item_eat(nut), selection_box = { @@ -82,8 +100,51 @@ for _, m in pairs(mushrooms_datas) do 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 + 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({ nodenames = {"group:flora"}, neighbors = {"default:dirt_with_grass", "default:desert_sand"}, @@ -94,7 +155,7 @@ minetest.register_abm({ local under = minetest.get_node(pos) pos.y = pos.y + 1 if under.name == "default:desert_sand" then - minetest.set_node(pos, {name="default:dry_shrub"}) + minetest.set_node(pos, {name = "default:dry_shrub"}) elseif under.name ~= "default:dirt_with_grass" then return end @@ -104,8 +165,8 @@ minetest.register_abm({ return end - local pos0 = {x=pos.x-4,y=pos.y-4,z=pos.z-4} - local pos1 = {x=pos.x+4,y=pos.y+4,z=pos.z+4} + local pos0 = {x = pos.x - 4, y = pos.y - 4, z = pos.z - 4} + local pos1 = {x = pos.x + 4, y = pos.y + 4, z = pos.z + 4} if #minetest.find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then return end @@ -124,7 +185,7 @@ minetest.register_abm({ return end if minetest.get_node(seedling).name == "air" then - minetest.set_node(seedling, {name=node.name}) + minetest.set_node(seedling, {name = node.name}) end end end, diff --git a/mods/flowers/textures/flowers_spores_brown.png b/mods/flowers/textures/flowers_spores_brown.png new file mode 100644 index 0000000000000000000000000000000000000000..a0818d23f0a2f7a3f2c25f61b44e34a002d3e9dc GIT binary patch literal 94 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`s-7;6Ar_~T6D00EsA4)?|4Z7V rG`c;bL1=Nsgm%$gpW6zrG%+wN?-JbD?;~yp)WG2B>gTe~DWM4fXE7Wj literal 0 HcmV?d00001 diff --git a/mods/flowers/textures/flowers_spores_red.png b/mods/flowers/textures/flowers_spores_red.png new file mode 100644 index 0000000000000000000000000000000000000000..1f1d3a4592af275bb1dd00dcfea73cd3094ca8c6 GIT binary patch literal 92 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`%APKcAr_~T6D00Eu$Q=a+hNsh qD;MS|5=WbD)?Aot-m_SYg~6(q|KstWS9pQS89ZJ6T-G@yGywoBP#ent literal 0 HcmV?d00001 -- 2.25.1