mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-04-30 05:01:41 -04:00
Added can_grow function to plant definition
This commit is contained in:
parent
511619253f
commit
d71123e337
2 changed files with 10 additions and 4 deletions
|
@ -382,6 +382,8 @@ The farming API allows you to easily register plants and hoes.
|
|||
-- ^ 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
|
||||
can_grow = function(pos) -- Сalled every growth tick to check if the plant can grow, returns bool
|
||||
-- (optional, checks for wet soil by default)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -224,11 +224,15 @@ farming.grow_plant = function(pos, elapsed)
|
|||
return
|
||||
end
|
||||
|
||||
-- check if on wet soil
|
||||
local below = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
if minetest.get_item_group(below.name, "soil") < 3 then
|
||||
tick_again(pos)
|
||||
if def.can_grow and not def.can_grow(pos) then
|
||||
return
|
||||
else
|
||||
-- check if on wet soil
|
||||
local below = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||
if minetest.get_item_group(below.name, "soil") < 3 then
|
||||
tick_again(pos)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- check light
|
||||
|
|
Loading…
Add table
Reference in a new issue