mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-29 13:53:43 +01:00
Add an option to disable the auto-cache
This commit is contained in:
parent
1910b4b345
commit
6d994fc8d5
26
init.lua
26
init.lua
@ -10,10 +10,12 @@ local fuel_cache = {}
|
|||||||
|
|
||||||
local toolrepair
|
local toolrepair
|
||||||
|
|
||||||
local progressive_mode = core.settings:get_bool("craftguide_progressive_mode")
|
local progressive_mode = core.settings:get_bool "craftguide_progressive_mode"
|
||||||
local sfinv_only = core.settings:get_bool("craftguide_sfinv_only") and rawget(_G, "sfinv")
|
local sfinv_only = core.settings:get_bool "craftguide_sfinv_only" and rawget(_G, "sfinv")
|
||||||
|
local autocache = core.settings:get_bool "craftguide_autocache"
|
||||||
|
|
||||||
local http = core.request_http_api()
|
local http = core.request_http_api()
|
||||||
|
local storage = core.get_mod_storage()
|
||||||
|
|
||||||
local reg_items = core.registered_items
|
local reg_items = core.registered_items
|
||||||
local reg_tools = core.registered_tools
|
local reg_tools = core.registered_tools
|
||||||
@ -130,7 +132,7 @@ craftguide.group_stereotypes = {
|
|||||||
mesecon_conductor_craftable = "mesecons:wire_00000000_off",
|
mesecon_conductor_craftable = "mesecons:wire_00000000_off",
|
||||||
}
|
}
|
||||||
|
|
||||||
local GROUP_NAMES = {
|
local group_names = {
|
||||||
coal = S"Any coal",
|
coal = S"Any coal",
|
||||||
wool = S"Any wool",
|
wool = S"Any wool",
|
||||||
wood = S"Any wood planks",
|
wood = S"Any wood planks",
|
||||||
@ -708,7 +710,7 @@ local function get_tooltip(name, info)
|
|||||||
|
|
||||||
if info.groups then
|
if info.groups then
|
||||||
sort(info.groups)
|
sort(info.groups)
|
||||||
tooltip = GROUP_NAMES[concat(info.groups, ",")]
|
tooltip = group_names[concat(info.groups, ",")]
|
||||||
|
|
||||||
if not tooltip then
|
if not tooltip then
|
||||||
local groupstr, c = {}, 0
|
local groupstr, c = {}, 0
|
||||||
@ -1470,6 +1472,12 @@ local function show_item(def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_init_items()
|
local function get_init_items()
|
||||||
|
if not autocache then
|
||||||
|
init_items = dslz(storage:get "init_items")
|
||||||
|
fuel_cache = dslz(storage:get "fuel_cache")
|
||||||
|
usages_cache = dslz(storage:get "usages_cache")
|
||||||
|
recipes_cache = dslz(storage:get "recipes_cache")
|
||||||
|
else
|
||||||
print "[craftguide] Caching data (this may take a while)"
|
print "[craftguide] Caching data (this may take a while)"
|
||||||
local hash = {}
|
local hash = {}
|
||||||
|
|
||||||
@ -1496,6 +1504,12 @@ local function get_init_items()
|
|||||||
handle_aliases(hash)
|
handle_aliases(hash)
|
||||||
sort(init_items)
|
sort(init_items)
|
||||||
|
|
||||||
|
storage:set_string("init_items", slz(init_items))
|
||||||
|
storage:set_string("fuel_cache", slz(fuel_cache))
|
||||||
|
storage:set_string("usages_cache", slz(usages_cache))
|
||||||
|
storage:set_string("recipes_cache", slz(recipes_cache))
|
||||||
|
end
|
||||||
|
|
||||||
if http and true_str(craftguide.export_url) then
|
if http and true_str(craftguide.export_url) then
|
||||||
local post_data = {
|
local post_data = {
|
||||||
recipes = recipes_cache,
|
recipes = recipes_cache,
|
||||||
@ -1957,8 +1971,8 @@ if progressive_mode then
|
|||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
|
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
data.inv_items = dslz(meta:get_string("inv_items")) or {}
|
data.inv_items = dslz(meta:get_string "inv_items") or {}
|
||||||
data.known_recipes = dslz(meta:get_string("known_recipes")) or 0
|
data.known_recipes = dslz(meta:get_string "known_recipes") or 0
|
||||||
|
|
||||||
data.hud = {
|
data.hud = {
|
||||||
bg = player:hud_add{
|
bg = player:hud_add{
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
# The progressive mode shows recipes you can craft from items you ever had in your inventory.
|
# The progressive mode shows recipes you can craft from items you ever had in your inventory.
|
||||||
craftguide_progressive_mode (Progressive Mode) bool false
|
craftguide_progressive_mode (Learn crafting recipes progressively) bool false
|
||||||
|
|
||||||
# Integration in the default Minetest Game inventory.
|
# Integration in the default Minetest Game inventory.
|
||||||
craftguide_sfinv_only (Sfinv only) bool false
|
craftguide_sfinv_only (Crafting Guide in inventory only) bool false
|
||||||
|
|
||||||
|
# Enable pre-caching of item recipes.
|
||||||
|
# Disabling it will result in faster game loading but lesser in-game efficiency.
|
||||||
|
# If you enable or disable mods, or edit the current mod recipes in your game, you should re-enable the cache,
|
||||||
|
# otherwise some recipes will be skipped or removed. Usage at your own risk.
|
||||||
|
craftguide_autocache (Auto-caching of recipes) bool true
|
||||||
|
Loading…
Reference in New Issue
Block a user