diff --git a/api.txt b/api.txt index 19481f4..26e4600 100644 --- a/api.txt +++ b/api.txt @@ -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 diff --git a/hoes.lua b/hoes.lua index 8dc921a..926aa42 100644 --- a/hoes.lua +++ b/hoes.lua @@ -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