minetest-i4/i4/init.lua
Jaidyn Ann 4c8688190a Add setting for inventory-size (i4_inventory_size)
Also removes the “legacy inventory” user-setting,
and defaults to 32 for inventory size.
I feel that the individual players shouldn’t be
able to tweak their inventory-size, that’s a
server-level sort of setting.
2024-01-15 12:52:18 -06:00

125 lines
2.6 KiB
Lua

local modpath = core.get_modpath"i4"
local http = core.request_http_api()
local storage = core.get_mod_storage()
local _loadfile = dofile(modpath .. "/src/preprocessor.lua")
local function lf(path)
return assert(_loadfile(modpath .. path))
end
i4 = {
version = 1162,
data = core.deserialize(storage:get_string"data") or {},
imported = storage:get_int"imported_from_i3",
settings = {
debug_mode = false,
max_favs = 6,
max_waypoints = 30,
min_fs_version = 6,
item_btn_size = 1.1,
drop_bag_on_die = true,
wielditem_fade_after = 3,
save_interval = 600, -- Player data save interval (in seconds)
hud_speed = 3,
hud_timer_max = 3,
damage_enabled = core.settings:get_bool"enable_damage",
progressive_mode = core.settings:get_bool"i4_progressive_mode" or core.settings:get_bool"i3_progressive_mode",
inventory_size = tonumber(core.settings:get"i4_inventory_size") or (storage:get_int"imported_from_i3" and 36),
},
categories = {
"crafting",
"armor",
"bag",
"skins",
"waypoints"
},
saves = { -- Metadata to save
bag = true,
home = true,
sort = true,
collapse = true,
font_size = true,
hide_tabs = true,
waypoints = true,
inv_items = true,
auto_sorting = true,
inv_compress = true,
known_recipes = true,
wielditem_hud = true,
ignore_hotbar = true,
reverse_sorting = true,
hotbar_len = true,
},
default_data = {
sort = 1,
font_size = 0,
collapse = true,
inv_compress = true,
hotbar_len = 8,
},
files = {
api = lf"/src/api.lua",
bags = lf"/src/bags.lua",
caches = lf"/src/caches.lua",
callbacks = lf"/src/callbacks.lua",
common = lf"/src/common.lua",
compress = lf"/src/compression.lua",
detached = lf"/src/detached_inv.lua",
fields = lf"/src/fields.lua",
groups = lf"/src/groups.lua",
gui = lf"/src/gui.lua",
hud = lf"/src/hud.lua",
model_alias = lf"/src/model_aliases.lua",
progressive = lf"/src/progressive.lua",
styles = lf"/src/styles.lua",
},
-- Caches
init_items = {},
fuel_cache = {},
usages_cache = {},
recipes_cache = {},
tabs = {},
cubes = {},
groups = {},
plants = {},
modules = {},
minitabs = {},
footer_buttons = {},
craft_types = {},
recipe_filters = {},
search_filters = {},
sorting_methods = {},
}
i3 = i4
i4.files.common()
i4.files.api(http)
i4.files.compress()
i4.files.detached()
i4.files.fields()
i4.files.groups()
i4.files.callbacks(http, storage)
if i4.settings.progressive_mode then
i4.files.progressive()
end
if i4.settings.debug_mode then
lf("/tests/test_tabs.lua")()
lf("/tests/test_waypoints.lua")()
-- lf("/tests/test_operators.lua")()
lf("/tests/test_compression.lua")()
lf("/tests/test_custom_recipes.lua")()
end