mirror of
https://github.com/minetest-mods/i3.git
synced 2025-07-03 09:00:23 +02:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
8afb51dae8 | |||
734b09b69f | |||
1560d59d4a | |||
e4e175a775 | |||
7a40f36611 | |||
2467e8bb0b | |||
9666834aed | |||
7670356c8c | |||
646d16afd8 | |||
6b54dbc934 | |||
911bed3911 | |||
75fdd57f2a | |||
c8d6312772 | |||
a4e8fac0e6 | |||
eac4a18df2 |
@ -10,6 +10,7 @@ read_globals = {
|
|||||||
"armor",
|
"armor",
|
||||||
"skins",
|
"skins",
|
||||||
"awards",
|
"awards",
|
||||||
|
"hb",
|
||||||
"vector",
|
"vector",
|
||||||
"string",
|
"string",
|
||||||
"table",
|
"table",
|
||||||
|
@ -55,4 +55,4 @@ Report bugs on the [**Bug Tracker**](https://github.com/minetest-mods/i3/issues)
|
|||||||
|
|
||||||
**Video review on YouTube:** https://www.youtube.com/watch?v=Xd14BCdEZ3o
|
**Video review on YouTube:** https://www.youtube.com/watch?v=Xd14BCdEZ3o
|
||||||
|
|
||||||

|

|
||||||
|
9
init.lua
9
init.lua
@ -20,7 +20,7 @@ local function lf(path)
|
|||||||
end
|
end
|
||||||
|
|
||||||
i3 = {
|
i3 = {
|
||||||
version = 1100,
|
version = 1113,
|
||||||
data = core.deserialize(storage:get_string"data") or {},
|
data = core.deserialize(storage:get_string"data") or {},
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
@ -30,6 +30,7 @@ i3 = {
|
|||||||
min_fs_version = 6,
|
min_fs_version = 6,
|
||||||
item_btn_size = 1.1,
|
item_btn_size = 1.1,
|
||||||
drop_bag_on_die = true,
|
drop_bag_on_die = true,
|
||||||
|
wielditem_fade_after = 3,
|
||||||
save_interval = 600, -- Player data save interval (in seconds)
|
save_interval = 600, -- Player data save interval (in seconds)
|
||||||
|
|
||||||
hud_speed = 1,
|
hud_speed = 1,
|
||||||
@ -37,7 +38,6 @@ i3 = {
|
|||||||
|
|
||||||
damage_enabled = core.settings:get_bool"enable_damage",
|
damage_enabled = core.settings:get_bool"enable_damage",
|
||||||
progressive_mode = core.settings:get_bool"i3_progressive_mode",
|
progressive_mode = core.settings:get_bool"i3_progressive_mode",
|
||||||
legacy_inventory = core.settings:get_bool"i3_legacy_inventory",
|
|
||||||
item_compression = core.settings:get_bool("i3_item_compression", true),
|
item_compression = core.settings:get_bool("i3_item_compression", true),
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -57,6 +57,8 @@ i3 = {
|
|||||||
waypoints = true,
|
waypoints = true,
|
||||||
inv_items = true,
|
inv_items = true,
|
||||||
known_recipes = true,
|
known_recipes = true,
|
||||||
|
wielditem_hud = true,
|
||||||
|
legacy_inventory = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
files = {
|
files = {
|
||||||
@ -94,9 +96,6 @@ i3 = {
|
|||||||
sorting_methods = {},
|
sorting_methods = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
i3.settings.hotbar_len = i3.settings.legacy_inventory and 8 or 9
|
|
||||||
i3.settings.inv_size = 4 * i3.settings.hotbar_len
|
|
||||||
|
|
||||||
i3.files.common()
|
i3.files.common()
|
||||||
i3.files.api(http)
|
i3.files.api(http)
|
||||||
i3.files.compress()
|
i3.files.compress()
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,4 +1,4 @@
|
|||||||
name = i3
|
name = i3
|
||||||
description = Next-generation inventory
|
description = Next-generation inventory
|
||||||
optional_depends = 3d_armor, skinsdb, awards
|
optional_depends = 3d_armor, skinsdb, awards
|
||||||
min_minetest_version = 5.4
|
min_minetest_version = 5.6
|
||||||
|
@ -3,6 +3,3 @@ i3_progressive_mode (Learn crafting recipes progressively) bool false
|
|||||||
|
|
||||||
# Regroup the items of the same type in the item list.
|
# Regroup the items of the same type in the item list.
|
||||||
i3_item_compression (Regroup items of the same type) bool true
|
i3_item_compression (Regroup items of the same type) bool true
|
||||||
|
|
||||||
# Set the inventory size to common chests size (8*4).
|
|
||||||
i3_legacy_inventory (Legacy inventory size) bool false
|
|
@ -2,7 +2,7 @@ local replacements = {fuel = {}}
|
|||||||
local http = ...
|
local http = ...
|
||||||
|
|
||||||
IMPORT("maxn", "copy", "insert", "sort", "match", "sub")
|
IMPORT("maxn", "copy", "insert", "sort", "match", "sub")
|
||||||
IMPORT("true_str", "is_table", "valid_item", "table_merge", "table_replace", "rcp_eq")
|
IMPORT("true_str", "is_table", "valid_item", "table_merge", "table_replace", "table_eq")
|
||||||
IMPORT("fmt", "reg_items", "reg_aliases", "reg_nodes", "is_cube", "get_cube", "ItemStack")
|
IMPORT("fmt", "reg_items", "reg_aliases", "reg_nodes", "is_cube", "get_cube", "ItemStack")
|
||||||
IMPORT("is_group", "extract_groups", "item_has_groups", "groups_to_items", "get_group_stereotype")
|
IMPORT("is_group", "extract_groups", "item_has_groups", "groups_to_items", "get_group_stereotype")
|
||||||
|
|
||||||
@ -248,11 +248,7 @@ local old_clear_craft = core.clear_craft
|
|||||||
core.clear_craft = function(def)
|
core.clear_craft = function(def)
|
||||||
old_clear_craft(def)
|
old_clear_craft(def)
|
||||||
|
|
||||||
if true_str(def) then
|
-- TODO: hide in crafting guide
|
||||||
return -- TODO
|
|
||||||
elseif is_table(def) then
|
|
||||||
return -- TODO
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function resolve_aliases(hash)
|
local function resolve_aliases(hash)
|
||||||
@ -274,7 +270,7 @@ local function resolve_aliases(hash)
|
|||||||
local rcp_new = copy(i3.recipes_cache[newname][j])
|
local rcp_new = copy(i3.recipes_cache[newname][j])
|
||||||
rcp_new.output = oldname
|
rcp_new.output = oldname
|
||||||
|
|
||||||
if rcp_eq(rcp_old, rcp_new) then
|
if table_eq(rcp_old, rcp_new) then
|
||||||
similar = true
|
similar = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,7 @@ local init_hud = i3.files.hud()
|
|||||||
local set_fs = i3.set_fs
|
local set_fs = i3.set_fs
|
||||||
|
|
||||||
IMPORT("slz", "min", "insert", "copy", "ItemStack")
|
IMPORT("slz", "min", "insert", "copy", "ItemStack")
|
||||||
IMPORT("spawn_item", "reset_data", "get_detached_inv", "play_sound")
|
IMPORT("spawn_item", "reset_data", "get_detached_inv", "play_sound", "update_inv_size")
|
||||||
|
|
||||||
core.register_on_player_hpchange(function(player, hpchange)
|
core.register_on_player_hpchange(function(player, hpchange)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
@ -148,6 +148,10 @@ if core.global_exists"skins" then
|
|||||||
i3.modules.skins = true
|
i3.modules.skins = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if core.global_exists"hb" then
|
||||||
|
i3.modules.hudbars = true
|
||||||
|
end
|
||||||
|
|
||||||
if core.global_exists"awards" then
|
if core.global_exists"awards" then
|
||||||
i3.modules.awards = true
|
i3.modules.awards = true
|
||||||
|
|
||||||
@ -226,8 +230,7 @@ local function init_data(player, info)
|
|||||||
data.lang_code = get_lang_code(info)
|
data.lang_code = get_lang_code(info)
|
||||||
data.fs_version = info.formspec_version
|
data.fs_version = info.formspec_version
|
||||||
|
|
||||||
local inv = player:get_inventory()
|
update_inv_size(player, data)
|
||||||
inv:set_size("main", i3.settings.inv_size)
|
|
||||||
|
|
||||||
core.after(0, set_fs, player)
|
core.after(0, set_fs, player)
|
||||||
end
|
end
|
||||||
|
@ -216,18 +216,22 @@ local function array_diff(t1, t2)
|
|||||||
return diff
|
return diff
|
||||||
end
|
end
|
||||||
|
|
||||||
local function rcp_eq(rcp, rcp2)
|
local function table_eq(t1, t2)
|
||||||
if rcp.type ~= rcp2.type then return end
|
local ty1, ty2 = type(t1), type(t2)
|
||||||
if rcp.width ~= rcp2.width then return end
|
if ty1 ~= ty2 then return end
|
||||||
if #rcp.items ~= #rcp2.items then return end
|
|
||||||
if rcp.output ~= rcp2.output then return end
|
|
||||||
|
|
||||||
for i, item in pairs(rcp.items) do
|
if ty1 ~= "table" and ty2 ~= "table" then
|
||||||
if item ~= rcp2.items[i] then return end
|
return t1 == t2
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, item in pairs(rcp2.items) do
|
for k, v in pairs(t1) do
|
||||||
if item ~= rcp.items[i] then return end
|
local v2 = t2[k]
|
||||||
|
if v2 == nil or not table_eq(v, v2) then return end
|
||||||
|
end
|
||||||
|
|
||||||
|
for k, v in pairs(t2) do
|
||||||
|
local v1 = t1[k]
|
||||||
|
if v1 == nil or not table_eq(v1, v) then return end
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@ -557,7 +561,7 @@ local function sort_inventory(player, data)
|
|||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local list = inv:get_list"main"
|
local list = inv:get_list"main"
|
||||||
local size = inv:get_size"main"
|
local size = inv:get_size"main"
|
||||||
local start_i = data.ignore_hotbar and (i3.settings.hotbar_len + 1) or 1
|
local start_i = data.ignore_hotbar and (data.hotbar_len + 1) or 1
|
||||||
|
|
||||||
if data.inv_compress then
|
if data.inv_compress then
|
||||||
list = compress_items(list, start_i)
|
list = compress_items(list, start_i)
|
||||||
@ -623,6 +627,24 @@ local function get_detached_inv(name, player_name)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function update_inv_size(player, data)
|
||||||
|
data.hotbar_len = data.legacy_inventory and 8 or 9
|
||||||
|
data.inv_size = 4 * data.hotbar_len
|
||||||
|
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
inv:set_size("main", data.inv_size)
|
||||||
|
|
||||||
|
player:hud_set_hotbar_itemcount(data.hotbar_len)
|
||||||
|
|
||||||
|
core.after(0, function()
|
||||||
|
if data.legacy_inventory then
|
||||||
|
player:hud_set_hotbar_image"gui_hotbar.png"
|
||||||
|
else
|
||||||
|
player:hud_set_hotbar_image"i3_hotbar.png"
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
-- Much faster implementation of `unpack`
|
-- Much faster implementation of `unpack`
|
||||||
local function createunpack(n)
|
local function createunpack(n)
|
||||||
local ret = {"local t = ... return "}
|
local ret = {"local t = ... return "}
|
||||||
@ -704,6 +726,7 @@ local _ = {
|
|||||||
-- Inventory
|
-- Inventory
|
||||||
get_stack = get_stack,
|
get_stack = get_stack,
|
||||||
craft_stack = craft_stack,
|
craft_stack = craft_stack,
|
||||||
|
update_inv_size = update_inv_size,
|
||||||
get_detached_inv = get_detached_inv,
|
get_detached_inv = get_detached_inv,
|
||||||
get_bag_description = get_bag_description,
|
get_bag_description = get_bag_description,
|
||||||
create_inventory = core.create_detached_inventory,
|
create_inventory = core.create_detached_inventory,
|
||||||
@ -745,7 +768,7 @@ local _ = {
|
|||||||
is_table = is_table,
|
is_table = is_table,
|
||||||
table_merge = table_merge,
|
table_merge = table_merge,
|
||||||
table_replace = table_replace,
|
table_replace = table_replace,
|
||||||
rcp_eq = rcp_eq,
|
table_eq = table_eq,
|
||||||
array_diff = array_diff,
|
array_diff = array_diff,
|
||||||
|
|
||||||
-- Math
|
-- Math
|
||||||
|
@ -10,6 +10,9 @@ local trash = create_inventory("i3_trash", {
|
|||||||
inv:set_list(listname, {})
|
inv:set_list(listname, {})
|
||||||
|
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
local data = i3.data[name]
|
||||||
|
data.armor_allow = nil
|
||||||
|
|
||||||
play_sound(name, "i3_trash", 1.0)
|
play_sound(name, "i3_trash", 1.0)
|
||||||
|
|
||||||
if not core.is_creative_enabled(name) then
|
if not core.is_creative_enabled(name) then
|
||||||
|
@ -5,8 +5,8 @@ IMPORT("min", "max", "vec_eq", "vec_round")
|
|||||||
IMPORT("S", "random", "translate", "ItemStack")
|
IMPORT("S", "random", "translate", "ItemStack")
|
||||||
IMPORT("sort", "copy", "insert", "remove", "indexof")
|
IMPORT("sort", "copy", "insert", "remove", "indexof")
|
||||||
IMPORT("fmt", "find", "match", "sub", "lower", "split", "toupper")
|
IMPORT("fmt", "find", "match", "sub", "lower", "split", "toupper")
|
||||||
IMPORT("search", "sort_inventory", "sort_by_category", "get_recipes", "get_detached_inv")
|
|
||||||
IMPORT("msg", "is_fav", "pos_to_str", "str_to_pos", "add_hud_waypoint", "play_sound", "reset_data")
|
IMPORT("msg", "is_fav", "pos_to_str", "str_to_pos", "add_hud_waypoint", "play_sound", "reset_data")
|
||||||
|
IMPORT("search", "sort_inventory", "sort_by_category", "get_recipes", "get_detached_inv", "update_inv_size")
|
||||||
IMPORT("valid_item", "get_stack", "craft_stack", "clean_name", "compressible", "check_privs", "safe_teleport")
|
IMPORT("valid_item", "get_stack", "craft_stack", "clean_name", "compressible", "check_privs", "safe_teleport")
|
||||||
|
|
||||||
local function inv_fields(player, data, fields)
|
local function inv_fields(player, data, fields)
|
||||||
@ -32,6 +32,10 @@ local function inv_fields(player, data, fields)
|
|||||||
data[str] = true
|
data[str] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if str == "legacy_inventory" then
|
||||||
|
update_inv_size(player, data)
|
||||||
|
end
|
||||||
|
|
||||||
elseif sub(field, 1, 8) == "setting_" then
|
elseif sub(field, 1, 8) == "setting_" then
|
||||||
data.show_setting = match(field, "_(%w+)$")
|
data.show_setting = match(field, "_(%w+)$")
|
||||||
|
|
||||||
|
60
src/gui.lua
60
src/gui.lua
@ -1,5 +1,4 @@
|
|||||||
local damage_enabled = i3.settings.damage_enabled
|
local damage_enabled = i3.settings.damage_enabled
|
||||||
local hotbar_len = i3.settings.hotbar_len
|
|
||||||
local debug_mode = i3.settings.debug_mode
|
local debug_mode = i3.settings.debug_mode
|
||||||
|
|
||||||
local model_aliases = i3.files.model_alias()
|
local model_aliases = i3.files.model_alias()
|
||||||
@ -128,10 +127,13 @@ local function get_stack_max(inv, data, is_recipe, rcp)
|
|||||||
return max_stacks
|
return max_stacks
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_inv_slots(fs)
|
local function get_inv_slots(data, fs)
|
||||||
local inv_x = i3.settings.legacy_inventory and 0.75 or 0.22
|
local legacy_inventory = data.legacy_inventory
|
||||||
local inv_y = 6.9
|
local hotbar_len = data.hotbar_len
|
||||||
local size, spacing = 1, 0.1
|
local inv_x = legacy_inventory and 0.23 or 0.22
|
||||||
|
local inv_y = legacy_inventory and 6.7 or 6.9
|
||||||
|
local spacing = legacy_inventory and 0.25 or 0.1
|
||||||
|
local size = 1
|
||||||
|
|
||||||
fs"style_type[box;colors=#77777710,#77777710,#777,#777]"
|
fs"style_type[box;colors=#77777710,#77777710,#777,#777]"
|
||||||
|
|
||||||
@ -142,11 +144,12 @@ local function get_inv_slots(fs)
|
|||||||
fs(fmt("style_type[list;size=%f;spacing=%f]", size, spacing),
|
fs(fmt("style_type[list;size=%f;spacing=%f]", size, spacing),
|
||||||
fmt("list[current_player;main;%f,%f;%u,1;]", inv_x, inv_y, hotbar_len))
|
fmt("list[current_player;main;%f,%f;%u,1;]", inv_x, inv_y, hotbar_len))
|
||||||
|
|
||||||
fs(fmt("style_type[list;size=%f;spacing=%f]", size, spacing),
|
fs(fmt("style_type[list;size=%f;spacing=%f,%f]", size, spacing, legacy_inventory and 0.15 or spacing))
|
||||||
fmt("list[current_player;main;%f,%f;%u,%u;%u]", inv_x, inv_y + 1.15,
|
|
||||||
hotbar_len, i3.settings.inv_size / hotbar_len, hotbar_len),
|
|
||||||
"style_type[list;size=1;spacing=0.15]")
|
|
||||||
|
|
||||||
|
fs(fmt("list[current_player;main;%f,%f;%u,%u;%u]", inv_x, inv_y + (legacy_inventory and 1.25 or 1.15),
|
||||||
|
hotbar_len, data.inv_size / hotbar_len, hotbar_len))
|
||||||
|
|
||||||
|
fs"style_type[list;size=1;spacing=0.15]"
|
||||||
fs"listring[current_player;craft]listring[current_player;main]"
|
fs"listring[current_player;craft]listring[current_player;main]"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -479,10 +482,11 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
|||||||
end
|
end
|
||||||
|
|
||||||
local armor_def = armor.def[name]
|
local armor_def = armor.def[name]
|
||||||
|
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
|
||||||
|
|
||||||
fs(fmt("list[detached:%s_armor;armor;0,%f;5,1;]", esc_name, yextra + 0.7))
|
fs(fmt("list[detached:%s_armor;armor;0,%f;5,1;]", esc_name, yextra + 0.7))
|
||||||
|
|
||||||
for i = 1, 5 do
|
for i = 1, 5 do
|
||||||
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
|
|
||||||
local stack = armor_inv:get_stack("armor", i)
|
local stack = armor_inv:get_stack("armor", i)
|
||||||
|
|
||||||
if stack:is_empty() then
|
if stack:is_empty() then
|
||||||
@ -624,19 +628,28 @@ local function show_settings(fs, data)
|
|||||||
|
|
||||||
elseif show_style then
|
elseif show_style then
|
||||||
checkbox(2.6, 9.95, "cb_hide_tabs", "Hide tabs", tostring(data.hide_tabs))
|
checkbox(2.6, 9.95, "cb_hide_tabs", "Hide tabs", tostring(data.hide_tabs))
|
||||||
|
checkbox(2.6, 10.4, "cb_legacy_inventory", "Legacy inventory", tostring(data.legacy_inventory))
|
||||||
|
checkbox(2.6, 10.85, "cb_wielditem_hud", "HUD description", tostring(data.wielditem_hud))
|
||||||
|
|
||||||
local sign = (data.font_size > 0 and "+") or (data.font_size > 0 and "-") or ""
|
local sign = (data.font_size > 0 and "+") or (data.font_size > 0 and "-") or ""
|
||||||
label(2.6, 10.45, ES"Font size" .. fmt(": %s", sign .. data.font_size))
|
label(5.3, 9.95, ES"Font size" .. fmt(": %s", sign .. data.font_size))
|
||||||
|
|
||||||
local range = 5
|
local range = 5
|
||||||
fs(fmt("scrollbaroptions[min=-%u;max=%u;smallstep=1;largestep=1;thumbsize=2]", range, range))
|
fs(fmt("scrollbaroptions[min=-%u;max=%u;smallstep=1;largestep=1;thumbsize=2]", range, range))
|
||||||
fs(fmt("scrollbar[2.6,10.65;2.5,0.3;horizontal;sb_font_size;%d]", data.font_size))
|
fs(fmt("scrollbar[5.3,10.25;2.45,0.3;horizontal;sb_font_size;%d]", data.font_size))
|
||||||
|
|
||||||
|
fs(fmt("tooltip[cb_hide_tabs;%s;#707070;#fff]",
|
||||||
|
ES"Enable this option to change the style of the right panel"),
|
||||||
|
fmt("tooltip[cb_legacy_inventory;%s;#707070;#fff]",
|
||||||
|
ES"Enable this option to set the classic inventory size in Minetest"),
|
||||||
|
fmt("tooltip[cb_wielditem_hud;%s;#707070;#fff]",
|
||||||
|
ES"Enable this option to show the wielded item description in your HUD"))
|
||||||
|
|
||||||
elseif show_sorting then
|
elseif show_sorting then
|
||||||
checkbox(2.6, 9.95, "cb_inv_compress", "Compression", tostring(data.inv_compress))
|
checkbox(2.6, 9.95, "cb_inv_compress", "Compression", tostring(data.inv_compress))
|
||||||
checkbox(2.6, 10.4, "cb_reverse_sorting", "Reverse mode", tostring(data.reverse_sorting))
|
checkbox(2.6, 10.4, "cb_reverse_sorting", "Reverse mode", tostring(data.reverse_sorting))
|
||||||
checkbox(2.6, 10.85, "cb_ignore_hotbar", "Ignore hotbar", tostring(data.ignore_hotbar))
|
checkbox(2.6, 10.85, "cb_ignore_hotbar", "Ignore hotbar", tostring(data.ignore_hotbar))
|
||||||
checkbox(5.5, 9.95, "cb_auto_sorting", "Automation", tostring(data.auto_sorting))
|
checkbox(5.4, 9.95, "cb_auto_sorting", "Automation", tostring(data.auto_sorting))
|
||||||
|
|
||||||
local methods = {}
|
local methods = {}
|
||||||
|
|
||||||
@ -645,13 +658,13 @@ local function show_settings(fs, data)
|
|||||||
insert(methods, name)
|
insert(methods, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
label(5.5, 10.4, ES"Sorting method:")
|
label(5.4, 10.4, ES"Sorting method:")
|
||||||
fs(fmt("dropdown[%f,%f;2.3,0.5;dd_sorting_method;%s;%u;true]",
|
fs(fmt("dropdown[%f,%f;2.4,0.5;dd_sorting_method;%s;%u;true]",
|
||||||
5.5, 10.6, concat(methods, ","), data.sort))
|
5.4, 10.6, concat(methods, ","), data.sort))
|
||||||
|
|
||||||
local desc = i3.sorting_methods[data.sort].description
|
local desc = i3.sorting_methods[data.sort].description
|
||||||
if desc then
|
if desc then
|
||||||
tooltip(5.5, 10.6, 2.3, 0.5, ESC(desc))
|
tooltip(5.4, 10.6, 2.4, 0.5, ESC(desc))
|
||||||
end
|
end
|
||||||
|
|
||||||
fs(fmt("tooltip[cb_inv_compress;%s;#707070;#fff]",
|
fs(fmt("tooltip[cb_inv_compress;%s;#707070;#fff]",
|
||||||
@ -669,10 +682,12 @@ end
|
|||||||
local function get_inventory_fs(player, data, fs)
|
local function get_inventory_fs(player, data, fs)
|
||||||
fs"listcolors[#bababa50;#bababa99]"
|
fs"listcolors[#bababa50;#bababa99]"
|
||||||
|
|
||||||
get_inv_slots(fs)
|
get_inv_slots(data, fs)
|
||||||
|
|
||||||
local props = player:get_properties()
|
local props = player:get_properties()
|
||||||
local ctn_len, ctn_hgt, yoffset = 5.7, 6.3, 0
|
local ctn_len = 5.7
|
||||||
|
local ctn_hgt = data.legacy_inventory and 6.1 or 6.3
|
||||||
|
local yoffset = 0
|
||||||
|
|
||||||
if props.mesh ~= "" then
|
if props.mesh ~= "" then
|
||||||
local anim = player:get_local_animation()
|
local anim = player:get_local_animation()
|
||||||
@ -696,6 +711,7 @@ local function get_inventory_fs(player, data, fs)
|
|||||||
|
|
||||||
local awards_unlocked, award_list, award_list_nb = 0
|
local awards_unlocked, award_list, award_list_nb = 0
|
||||||
local max_val = damage_enabled and 12 or 7
|
local max_val = damage_enabled and 12 or 7
|
||||||
|
max_val += (data.legacy_inventory and 2 or 0)
|
||||||
local bag_size = get_group(ItemStack(data.bag):get_name(), "bag")
|
local bag_size = get_group(ItemStack(data.bag):get_name(), "bag")
|
||||||
|
|
||||||
if data.subcat == 1 and bag_size > 0 then
|
if data.subcat == 1 and bag_size > 0 then
|
||||||
@ -1666,10 +1682,10 @@ local function make_fs(player, data)
|
|||||||
get_panels(fs, data, player)
|
get_panels(fs, data, player)
|
||||||
else
|
else
|
||||||
get_items_fs(fs, data, player, full_height)
|
get_items_fs(fs, data, player, full_height)
|
||||||
end
|
|
||||||
|
|
||||||
if not data.hide_tabs then
|
if not data.hide_tabs then
|
||||||
get_minitabs(fs, data, full_height)
|
get_minitabs(fs, data, full_height)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local visible_tabs = #i3.tabs
|
local visible_tabs = #i3.tabs
|
||||||
|
60
src/hud.lua
60
src/hud.lua
@ -1,4 +1,4 @@
|
|||||||
IMPORT("get_connected_players", "str_to_pos", "add_hud_waypoint")
|
IMPORT("ceil", "get_connected_players", "str_to_pos", "add_hud_waypoint")
|
||||||
|
|
||||||
local function init_hud(player)
|
local function init_hud(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
@ -32,14 +32,18 @@ local function init_hud(player)
|
|||||||
z_index = 0xDEAD,
|
z_index = 0xDEAD,
|
||||||
style = 1,
|
style = 1,
|
||||||
},
|
},
|
||||||
}
|
|
||||||
|
|
||||||
if not i3.settings.legacy_inventory then
|
wielditem = player:hud_add {
|
||||||
core.after(0, function()
|
hud_elem_type = "text",
|
||||||
player:hud_set_hotbar_itemcount(i3.settings.hotbar_len)
|
position = {x = 0.5, y = 1},
|
||||||
player:hud_set_hotbar_image"i3_hotbar.png"
|
offset = {x = 0, y = -65 - (i3.modules.hudbars and (ceil(hb.hudbars_count / 2) * 25) or 25)},
|
||||||
end)
|
alignment = {x = 0, y = -1},
|
||||||
end
|
number = 0xffffff,
|
||||||
|
text = "",
|
||||||
|
z_index = 0xDEAD,
|
||||||
|
style = 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function show_hud(player, data)
|
local function show_hud(player, data)
|
||||||
@ -91,6 +95,46 @@ local function show_hud(player, data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
core.register_globalstep(function(dt)
|
||||||
|
local players = get_connected_players()
|
||||||
|
players[0] = #players
|
||||||
|
|
||||||
|
for i = 1, players[0] do
|
||||||
|
local player = players[i]
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local data = i3.data[name]
|
||||||
|
if not data then return end
|
||||||
|
|
||||||
|
if not data.wielditem_hud then
|
||||||
|
player:hud_change(data.hud.wielditem, "text", "")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
data.timer = (data.timer or 0) + dt
|
||||||
|
local wieldidx = player:get_wield_index()
|
||||||
|
|
||||||
|
if wieldidx == data.old_wieldidx then
|
||||||
|
if data.timer >= i3.settings.wielditem_fade_after then
|
||||||
|
player:hud_change(data.hud.wielditem, "text", "")
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
data.timer = 0
|
||||||
|
data.old_wieldidx = wieldidx
|
||||||
|
|
||||||
|
local wielditem = player:get_wielded_item()
|
||||||
|
local meta = wielditem:get_meta()
|
||||||
|
|
||||||
|
local meta_desc = meta:get_string"short_description"
|
||||||
|
meta_desc = meta_desc:gsub("\27", "")
|
||||||
|
meta_desc = core.strip_colors(meta_desc)
|
||||||
|
|
||||||
|
local desc = meta_desc ~= "" and meta_desc or wielditem:get_short_description()
|
||||||
|
player:hud_change(data.hud.wielditem, "text", desc:trim())
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
core.register_globalstep(function()
|
core.register_globalstep(function()
|
||||||
local players = get_connected_players()
|
local players = get_connected_players()
|
||||||
players[0] = #players
|
players[0] = #players
|
||||||
|
@ -11,32 +11,39 @@ mt3:get_meta():set_string("description", "Worn Pick")
|
|||||||
mt3:get_meta():set_string("color", "yellow")
|
mt3:get_meta():set_string("color", "yellow")
|
||||||
mt3:set_wear(10000)
|
mt3:set_wear(10000)
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft {
|
||||||
output = mt:to_string(),
|
output = mt:to_string(),
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
recipe = {
|
recipe = {
|
||||||
"default:wood",
|
"default:wood",
|
||||||
mt2:to_string(),
|
mt2:to_string(),
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft {
|
||||||
output = mt3:to_string(),
|
output = mt3:to_string(),
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
recipe = {
|
recipe = {
|
||||||
"default:pick_mese",
|
"default:pick_mese",
|
||||||
"default:diamond",
|
"default:diamond",
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
|
|
||||||
|
minetest.clear_craft {
|
||||||
|
recipe = {
|
||||||
|
{"default:sand", "default:sand"},
|
||||||
|
{"default:sand", "default:sand"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
i3.register_craft {
|
i3.register_craft {
|
||||||
url = "https://raw.githubusercontent.com/minetest-mods/i3/main/tests/test_online_recipe.json"
|
url = "https://raw.githubusercontent.com/minetest-mods/i3/main/tests/test_online_recipe.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
result = "default:ladder_wood 2",
|
result = "default:ladder_wood 2",
|
||||||
items = {"default:copper_ingot 7, default:tin_ingot, default:steel_ingot 2"},
|
items = {"default:copper_ingot 7, default:tin_ingot, default:steel_ingot 2"},
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft {
|
i3.register_craft {
|
||||||
result = "default:tree",
|
result = "default:tree",
|
||||||
@ -56,7 +63,7 @@ i3.register_craft {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X",
|
"X",
|
||||||
"#",
|
"#",
|
||||||
@ -68,9 +75,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X",
|
"X",
|
||||||
"#X",
|
"#X",
|
||||||
@ -82,9 +89,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X",
|
"X",
|
||||||
},
|
},
|
||||||
@ -93,10 +100,10 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X#",
|
"X#",
|
||||||
},
|
},
|
||||||
@ -105,9 +112,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X#X",
|
"X#X",
|
||||||
},
|
},
|
||||||
@ -116,9 +123,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X#XX",
|
"X#XX",
|
||||||
},
|
},
|
||||||
@ -127,9 +134,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X#XX",
|
"X#XX",
|
||||||
"X#X",
|
"X#X",
|
||||||
@ -139,9 +146,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X#XX",
|
"X#XX",
|
||||||
"X#X",
|
"X#X",
|
||||||
@ -152,9 +159,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X##XX",
|
"X##XX",
|
||||||
},
|
},
|
||||||
@ -163,9 +170,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X##X#X",
|
"X##X#X",
|
||||||
},
|
},
|
||||||
@ -174,9 +181,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X##X#X",
|
"X##X#X",
|
||||||
"",
|
"",
|
||||||
@ -187,9 +194,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
@ -201,9 +208,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass 2",
|
['X'] = "default:glass 2",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
@ -215,9 +222,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass",
|
['X'] = "default:glass",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
@ -230,9 +237,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass",
|
['X'] = "default:glass",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
@ -245,10 +252,10 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass",
|
['X'] = "default:glass",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
@ -262,9 +269,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass",
|
['X'] = "default:glass",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
@ -278,9 +285,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass",
|
['X'] = "default:glass",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
@ -294,9 +301,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass",
|
['X'] = "default:glass",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
@ -310,9 +317,9 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass",
|
['X'] = "default:glass",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft {
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
" ## ",
|
" ## ",
|
||||||
@ -328,4 +335,4 @@ i3.register_craft({
|
|||||||
['X'] = "default:glass",
|
['X'] = "default:glass",
|
||||||
},
|
},
|
||||||
result = "default:mese 3",
|
result = "default:mese 3",
|
||||||
})
|
}
|
||||||
|
Reference in New Issue
Block a user