From 4b50088b6ed276992c11b4ca15a1b27aaeefdd9a Mon Sep 17 00:00:00 2001 From: ssdaniel24 Date: Tue, 11 Jun 2024 23:36:35 +0300 Subject: [PATCH] Added new param soil_group to plant def --- game_api.txt | 3 ++- mods/farming/api.lua | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/game_api.txt b/game_api.txt index b3f6efc61c..85d9f93309 100644 --- a/game_api.txt +++ b/game_api.txt @@ -381,7 +381,8 @@ The farming API allows you to easily register plants and hoes. steps = 8, -- How many steps the plant has to grow, until it can be harvested -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber) minlight = 13, -- Minimum light to grow - maxlight = default.LIGHT_MAX -- Maximum light to grow + maxlight = default.LIGHT_MAX, -- Maximum light to grow + soil_group = "soil" -- Soil node group where plant can grow ("soil" by default) } diff --git a/mods/farming/api.lua b/mods/farming/api.lua index 96f9f63688..01f3a25fd6 100644 --- a/mods/farming/api.lua +++ b/mods/farming/api.lua @@ -130,7 +130,7 @@ local function tick_again(pos) end -- Seed placement -farming.place_seed = function(itemstack, placer, pointed_thing, plantname) +farming.place_seed = function(itemstack, placer, pointed_thing, plantname, soil_group) local pt = pointed_thing -- check if pointing at a node if not pt then @@ -173,7 +173,7 @@ farming.place_seed = function(itemstack, placer, pointed_thing, plantname) end -- check if pointing at soil - if minetest.get_item_group(under.name, "soil") < 2 then + if minetest.get_item_group(under.name, soil_group) < 2 then return itemstack end @@ -279,6 +279,9 @@ farming.register_plant = function(name, def) if not def.fertility then def.fertility = {} end + if not def.soil_group then + def.soil_group = "soil" + end farming.registered_plants[pname] = def @@ -322,7 +325,7 @@ farming.register_plant = function(name, def) pointed_thing) or itemstack end - return farming.place_seed(itemstack, placer, pointed_thing, mname .. ":seed_" .. pname) + return farming.place_seed(itemstack, placer, pointed_thing, mname .. ":seed_" .. pname, def.soil_group) end, next_plant = mname .. ":" .. pname .. "_1", on_timer = farming.grow_plant,