mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-04-30 13:11:41 -04:00
Added new param soil_group to plant def
This commit is contained in:
parent
511619253f
commit
9fe78ec3f0
2 changed files with 7 additions and 3 deletions
|
@ -381,7 +381,9 @@ 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).
|
||||
-- Group rating must be at least 2 for plant growing.
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -173,7 +173,8 @@ 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
|
||||
local soil_group = farming.registered_plants[plantname].soil_group
|
||||
if minetest.get_item_group(under.name, soil_group) < 2 then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
|
@ -279,6 +280,7 @@ farming.register_plant = function(name, def)
|
|||
if not def.fertility then
|
||||
def.fertility = {}
|
||||
end
|
||||
def.soil_group = def.soil_group or "soil"
|
||||
|
||||
farming.registered_plants[pname] = def
|
||||
|
||||
|
@ -322,7 +324,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,
|
||||
|
|
Loading…
Add table
Reference in a new issue