From b7a149a2fa3a3a21813cb082fca9703eb72475a4 Mon Sep 17 00:00:00 2001 From: Olivier Dragon Date: Fri, 22 Apr 2022 14:07:22 -0400 Subject: [PATCH] Make doc (and progressive reveal) optional --- .gitattributes | 1 + init.lua | 8 +++++++- mod.conf | 6 +++--- reveal.lua | 10 ++++++---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.gitattributes b/.gitattributes index 031d8f6..e60a2f0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -17,4 +17,5 @@ LICENSE text *.xcf binary .* export-ignore +*.cdb.json export-ignore Screenshot.* export-ignore diff --git a/init.lua b/init.lua index bef00db..f7aec46 100644 --- a/init.lua +++ b/init.lua @@ -18,8 +18,14 @@ function sfcg.get_recipes(data, item) return sfcg.recipes_cache[item] end +-- Loading components + 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 dofile(modpath.."/sfinv.lua") end diff --git a/mod.conf b/mod.conf index c4070e2..f3f499f 100644 --- a/mod.conf +++ b/mod.conf @@ -1,5 +1,5 @@ name = sfcraftguide -description = An augmented mtg_craftguide. Supports a progressive reveal system that can follow docs item help. -depends = doc, doc_items -optional_depends = sfinv +description = An augmented mtg_craftguide. Supports a progressive reveal system that follows docs item help. +depends = +optional_depends = sfinv, doc, doc_items min_minetest_version = 5.0 diff --git a/reveal.lua b/reveal.lua index 1cd403c..3fd9674 100644 --- a/reveal.lua +++ b/reveal.lua @@ -55,11 +55,7 @@ local function revealed_show_recipe(recipe, playername) end -local orig_execute_search = sfcg.execute_search 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) local recipes = orig_get_usages(data, item) if not recipes then @@ -77,6 +73,8 @@ function sfcg.get_usages(data, item) end end + +local orig_get_recipes = sfcg.get_recipes function sfcg.get_recipes(data, item) local recipes = orig_get_recipes(data, item) if not recipes then @@ -94,6 +92,8 @@ function sfcg.get_recipes(data, item) end end + +local orig_execute_search = sfcg.execute_search function sfcg.execute_search(data) -- Only needed if doc is an optional dependency -- @@ -125,6 +125,8 @@ local function async_update() end end + +local orig_mark_entry_as_revealed = doc.mark_entry_as_revealed 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 -- if not doc.entry_revealed(playername, category_id, entry_id) then