fix api.txt hoe recipe, add check for register_hoe recipe (thx the4codeblocks)

This commit is contained in:
tenplus1
2025-12-27 08:05:11 +00:00
parent 9cb83d03b5
commit 0f07c2975c
2 changed files with 11 additions and 16 deletions

View File

@@ -27,8 +27,8 @@ The farming API allows you to easily register plants and hoes.
material = "", -- Material for recipes
recipe = { -- Craft recipe, if material isn't used
{"air", "air", "air"},
{"", "group:stick"},
{"", "group:stick"},
{"", "group:stick", ""},
{"", "group:stick", ""},
}
}
@@ -40,7 +40,7 @@ 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 = minetest.LIGHT_MAX -- Maximum light to grow
maxlight = core.LIGHT_MAX -- Maximum light to grow
can_grow = function(pos) -- Called every growth tick to check if plant can grow returning True if needs are met (optional, defaults to checking for wet soil below plant).
}
@@ -52,7 +52,7 @@ If a mod registers nodes to be used as crops using the {growing=1} group then an
growth_check = function(pos, [node_name]) [DEPRECATED for above can_grow function]
-- check surrounding for jungle tree
if minetest.find_node_near(pos, 1, {"default:jungletree"}) then
if core.find_node_near(pos, 1, {"default:jungletree"}) then
return true -- place next growth stage
end
return false -- condition not met, skip next growth stage until next check

View File

@@ -36,19 +36,14 @@ farming.register_hoe = function(name, def)
})
-- Register its recipe
if def.recipe then
core.register_craft({ output = name:sub(2), recipe = def.recipe })
local recipe = def.recipe or (def.material and {
{def.material, def.material},
{"", "group:stick"},
{"", "group:stick"}
})
elseif def.material then
core.register_craft({
output = name:sub(2),
recipe = {
{def.material, def.material, ""},
{"", "group:stick", ""},
{"", "group:stick", ""}
}
})
if recipe then
core.register_craft({ output = name:sub(2), recipe = recipe })
end
end