Skip to content

Commit

Permalink
Make doc (and progressive reveal) optional
Browse files Browse the repository at this point in the history
  • Loading branch information
dacmot committed Apr 22, 2022
1 parent c939ce0 commit b7a149a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ LICENSE text
*.xcf binary

.* export-ignore
*.cdb.json export-ignore
Screenshot.* export-ignore
8 changes: 7 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions mod.conf
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions reveal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
--
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b7a149a

Please sign in to comment.