@@ -2,6 +2,8 @@ local S = minetest.get_translator("unified_inventory")
22local F = minetest .formspec_escape
33local ui = unified_inventory
44
5+ local recipes_initialized = false
6+
57--- @return boolean. Returns ` true` when all ingredients exist.
68local function is_recipe_craftable (recipe )
79 -- Ensure the ingedients exist
@@ -201,6 +203,7 @@ minetest.after(0.01, function()
201203 end
202204 ui .crafts_for .recipe [outputitemname ] = new_recipe_list
203205 end
206+ recipes_initialized = true
204207
205208 -- Remove unknown items from all categories
206209 local total_removed = 0
@@ -292,6 +295,15 @@ function ui.register_craft(options)
292295 return
293296 end
294297
298+ if recipes_initialized then
299+ -- If you're getting this warning, do use either:
300+ -- a) unified_inventory.register_craft(...)
301+ -- b) core.register_on_mods_loaded(...)
302+ core .log (" warning" , " [unified_inventory] Recipe registered too late: " ..
303+ dump (options .output ):gsub (" [\t\n ]" , " " ) ..
304+ " . It might not show up correctly." )
305+ end
306+
295307 if options .type == " normal" and options .width == 0 then
296308 options = {
297309 type = " shapeless" ,
@@ -308,7 +320,7 @@ function ui.register_craft(options)
308320 -- Most common
309321 outputs = { outputs }
310322 elseif type (outputs ) == " userdata" and outputs .add_item then
311- -- Rare
323+ -- Rare: ItemStack
312324 outputs = { outputs }
313325 end
314326 assert (type (outputs ) == " table" , " Invalid 'output' field: " .. type (options .output ))
0 commit comments