forked from minetest-mods/craftguide
Fix non-shown recipes
This commit is contained in:
parent
768e06e2d0
commit
a936452e21
20
init.lua
20
init.lua
|
@ -23,6 +23,7 @@ local globalstep = core.register_globalstep
|
|||
local on_shutdown = core.register_on_shutdown
|
||||
local get_players = core.get_connected_players
|
||||
local on_joinplayer = core.register_on_joinplayer
|
||||
local get_all_recipes = core.get_all_craft_recipes
|
||||
local register_command = core.register_chatcommand
|
||||
local get_player_by_name = core.get_player_by_name
|
||||
local on_mods_loaded = core.register_on_mods_loaded
|
||||
|
@ -382,6 +383,21 @@ local function cache_usages(item)
|
|||
end
|
||||
end
|
||||
|
||||
local function cache_recipes(output)
|
||||
local recipes = get_all_recipes(output) or {}
|
||||
local num = #recipes
|
||||
|
||||
if num > 0 then
|
||||
if recipes_cache[output] then
|
||||
for i = 1, num do
|
||||
insert(recipes_cache[output], 1, recipes[i])
|
||||
end
|
||||
else
|
||||
recipes_cache[output] = recipes
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function get_recipes(item, data, player)
|
||||
local recipes = recipes_cache[item]
|
||||
local usages = usages_cache[item]
|
||||
|
@ -935,6 +951,10 @@ local function get_init_items()
|
|||
if show_item(def) then
|
||||
cache_usages(name)
|
||||
|
||||
if not recipes_cache[name] then
|
||||
cache_recipes(name)
|
||||
end
|
||||
|
||||
if recipes_cache[name] or usages_cache[name] then
|
||||
init_items[c] = name
|
||||
c = c + 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user