Make doc (and progressive reveal) optional

master
Olivier Dragon 2022-04-22 14:07:22 -04:00
parent c939ce0fb7
commit b7a149a2fa
4 changed files with 17 additions and 8 deletions

1
.gitattributes vendored
View File

@ -17,4 +17,5 @@ LICENSE text
*.xcf binary *.xcf binary
.* export-ignore .* export-ignore
*.cdb.json export-ignore
Screenshot.* export-ignore Screenshot.* export-ignore

View File

@ -18,8 +18,14 @@ function sfcg.get_recipes(data, item)
return sfcg.recipes_cache[item] return sfcg.recipes_cache[item]
end end
-- Loading components
dofile(modpath.."/craftguide.lua") dofile(modpath.."/craftguide.lua")
dofile(modpath.."/reveal.lua")
if (minetest.get_modpath("doc") and minetest.get_modpath("doc_items")) then
dofile(modpath.."/reveal.lua")
end
if (minetest.get_modpath("sfinv") and minetest.global_exists("sfinv")) and sfinv.enabled then if (minetest.get_modpath("sfinv") and minetest.global_exists("sfinv")) and sfinv.enabled then
dofile(modpath.."/sfinv.lua") dofile(modpath.."/sfinv.lua")
end end

View File

@ -1,5 +1,5 @@
name = sfcraftguide name = sfcraftguide
description = An augmented mtg_craftguide. Supports a progressive reveal system that can follow docs item help. description = An augmented mtg_craftguide. Supports a progressive reveal system that follows docs item help.
depends = doc, doc_items depends =
optional_depends = sfinv optional_depends = sfinv, doc, doc_items
min_minetest_version = 5.0 min_minetest_version = 5.0

View File

@ -55,11 +55,7 @@ local function revealed_show_recipe(recipe, playername)
end end
local orig_execute_search = sfcg.execute_search
local orig_get_usages = sfcg.get_usages local orig_get_usages = sfcg.get_usages
local orig_get_recipes = sfcg.get_recipes
local orig_mark_entry_as_revealed = doc.mark_entry_as_revealed
function sfcg.get_usages(data, item) function sfcg.get_usages(data, item)
local recipes = orig_get_usages(data, item) local recipes = orig_get_usages(data, item)
if not recipes then if not recipes then
@ -77,6 +73,8 @@ function sfcg.get_usages(data, item)
end end
end end
local orig_get_recipes = sfcg.get_recipes
function sfcg.get_recipes(data, item) function sfcg.get_recipes(data, item)
local recipes = orig_get_recipes(data, item) local recipes = orig_get_recipes(data, item)
if not recipes then if not recipes then
@ -94,6 +92,8 @@ function sfcg.get_recipes(data, item)
end end
end end
local orig_execute_search = sfcg.execute_search
function sfcg.execute_search(data) function sfcg.execute_search(data)
-- Only needed if doc is an optional dependency -- Only needed if doc is an optional dependency
-- --
@ -125,6 +125,8 @@ local function async_update()
end end
end end
local orig_mark_entry_as_revealed = doc.mark_entry_as_revealed
function doc.mark_entry_as_revealed(playername, category_id, entry_id) function doc.mark_entry_as_revealed(playername, category_id, entry_id)
-- Temp Fix: `doc.entry_revealed()` crashes on some items like farming:* because they're given the wrong category_id -- Temp Fix: `doc.entry_revealed()` crashes on some items like farming:* because they're given the wrong category_id
-- if not doc.entry_revealed(playername, category_id, entry_id) then -- if not doc.entry_revealed(playername, category_id, entry_id) then