commit 7b301db9671040e8d157a373f4f22e1716c6bacd Author: Zenon Seth Date: Fri Oct 13 02:25:46 2023 +0100 Initial work, functioning flowerbeds diff --git a/README.md b/README.md new file mode 100644 index 0000000..ff39079 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Flowerbeds +Flowerbeds are blocks that allow easier growing of flowers. +Once you place a flower on top of a flowerbed, it will quickly grow in nearby empty flowerbeds. + +This growing is not limited by the usual restriction of flora density, so a single flower planted in a large flowerbed field will eventually fill the entire field with the flower. + +In order to grow new flowers, flowerbeds must be on the same vertical height, and adjecent - even diagonally - to each other. + +Flowerbeds are crafted from 1 coal, 1 dirt and 1 wood placed vertically. Different woods yields different looking flowerbeds, but they all share the same functionality and can work with each other. \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..a660e8e --- /dev/null +++ b/init.lua @@ -0,0 +1,81 @@ +-- flowerbeds = {} +-- local flowerbedNodes = {} +local baseMatsAndTextures = { + {"default:wood", "default_wood.png"}, + {"default:junglewood", "default_junglewood.png"}, + {"default:acacia_wood", "default_acacia_wood.png"}, + {"default:pine_wood", "default_pine_wood.png"}, + {"default:aspen_wood", "default_aspen_wood.png"} + -- perhaps too many, unecessary + -- {"default:stonebrick", "default_stone_brick.png"}, + -- {"default:stone_block", "default_stone_block.png"}, + -- {"default:desert_stonebrick", "default_desert_stone_brick.png"}, + -- {"default:desert_stone_block", "default_desert_stone_block.png"}, + -- {"default:sandstonebrick", "default_sandstone_brick.png"}, + -- {"default:sandstone_block", "default_sandstone_block.png"}, + -- {"default:desert_sandstone_brick", "default_desert_sandstone_brick.png"}, + -- {"default:desert_sandstone_block", "default_desert_sandstone_block.png"}, + -- {"default:silver_sandstone_brick", "default_silver_sandstone_brick.png"}, + -- {"default:silver_sandstone_block", "default_silver_sandstone_block.png"} +} + +local getBasicFlowerbedDef = function(baseTexture) + return { + drawtype = "normal",--"glasslike_framed", + description = "Basic Flowerbed", + tiles = { + baseTexture.."^flowerbed_basic.png", + baseTexture.."^flowerbed_trim.png" + }, + connects_to = {"group:basicFlowerbed"}, + groups = {choppy = 3, oddly_breakable_by_hand = 3, flowerbed = 1}, + sounds = default.node_sound_wood_defaults() + } +end + +local basic_flowerbed_abm = function(pos, node, active_object_count, active_object_count_wider) + local checkAdj = {{1, 1}, {1, 0}, {1, -1}, {0, 1}, {0, -1}, {-1, 1}, {-1, 0}, {-1, -1}} + pos.y = pos.y + 1 + local nodeAbove = minetest.get_node_or_nil(pos) + if not nodeAbove or not nodeAbove.name == "air" then + return + end + for _, adj in pairs(checkAdj) do + local checkPos = {x = pos.x + adj[1], y = pos.y, z = pos.z + adj[2]} + local checkNode = minetest.get_node_or_nil(checkPos) + if checkNode and minetest.get_item_group(checkNode.name, "flower") > 0 then + minetest.set_node(pos, checkNode) -- copy the flower + return + end + end +end +-------------------------------- +-- minetest calls +-------------------------------- + +for _, data in pairs(baseMatsAndTextures) do + local def = getBasicFlowerbedDef(data[2]) + local name = "flowerbeds:basic_"..string.sub(data[1],9,-1) + minetest.register_node(name , def) + + minetest.register_craft({ + output = name, + recipe = { + {"default:coal_lump"}, + {"default:dirt"}, + {data[1]} + } + }) + + minetest.register_abm({ + label = "ABM for "..name, + nodenames = {name}, + neighbors = {"air"}, + interval = 11.0, + chance = 40, + min_y = -50, + catch_up = true, + action = basic_flowerbed_abm + }) + +end \ No newline at end of file diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..5097d4c --- /dev/null +++ b/mod.conf @@ -0,0 +1,7 @@ +name = flowerbeds +depends = flowers, default +min_minetest_version = 4.7.0 +release = 1000 +author = ZenonSeth +description = Flower Beds for growing flowers +title = Flower Beds diff --git a/textures/flowerbed_basic.png b/textures/flowerbed_basic.png new file mode 100644 index 0000000..920541d Binary files /dev/null and b/textures/flowerbed_basic.png differ diff --git a/textures/flowerbed_trim.png b/textures/flowerbed_trim.png new file mode 100644 index 0000000..b375255 Binary files /dev/null and b/textures/flowerbed_trim.png differ