mirror of
https://github.com/minetest-mods/i3.git
synced 2025-07-03 00:50:22 +02:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
815651a32f | |||
b8db525dac | |||
cbf6256593 | |||
893959b5d4 | |||
8a5a14747e | |||
b53959f177 | |||
685b40f318 | |||
e96d279d29 | |||
c87a179cb5 | |||
7e2256253d | |||
f2cc874ec0 | |||
5c96ede065 | |||
1c4ae1df28 | |||
970220c561 | |||
4ca50e846d | |||
0ab3dd5ffa | |||
7820d88a30 | |||
34841eddf3 | |||
6f588e1927 | |||
d0ff046873 |
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
|
||||||
|
[*.{lua,txt,md,json}]
|
||||||
|
charset = utf8
|
||||||
|
indent_size = 8
|
||||||
|
indent_style = tab
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
8
API.md
8
API.md
@ -38,10 +38,14 @@ i3.new_tab {
|
|||||||
|
|
||||||
Updates the current formspec. `extra_formspec` adds an additional formspec string.
|
Updates the current formspec. `extra_formspec` adds an additional formspec string.
|
||||||
|
|
||||||
#### `i3.delete_tab(tabname)`
|
#### `i3.remove_tab(tabname)`
|
||||||
|
|
||||||
Deletes a tab by name.
|
Deletes a tab by name.
|
||||||
|
|
||||||
|
#### `i3.get_current_tab(player)`
|
||||||
|
|
||||||
|
Returns the current player tab. `player` is an `ObjectRef` to the user.
|
||||||
|
|
||||||
#### `i3.set_tab(player[, tabname])`
|
#### `i3.set_tab(player[, tabname])`
|
||||||
|
|
||||||
Sets the current tab by name. `player` is an `ObjectRef` to the user.
|
Sets the current tab by name. `player` is an `ObjectRef` to the user.
|
||||||
@ -178,7 +182,7 @@ end)
|
|||||||
|
|
||||||
Removes all recipe filters and adds a new one.
|
Removes all recipe filters and adds a new one.
|
||||||
|
|
||||||
#### `i3.delete_recipe_filter(name)`
|
#### `i3.remove_recipe_filter(name)`
|
||||||
|
|
||||||
Removes the recipe filter with the given `name`.
|
Removes the recipe filter with the given `name`.
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ To enable it: `i3_progressive_mode = true` in `minetest.conf`.*
|
|||||||
|
|
||||||
#### Recommendations
|
#### Recommendations
|
||||||
|
|
||||||
To use this mod in the best conditions, it's recommended to follow these recommendations:
|
To use this mod in the best conditions:
|
||||||
|
|
||||||
- Use LuaJIT
|
- Use LuaJIT
|
||||||
- Use a HiDPI widescreen display
|
- Use a HiDPI widescreen display
|
||||||
@ -49,4 +49,4 @@ Love this mod? Donations are appreciated: https://www.paypal.me/jpg84240
|
|||||||
|
|
||||||
Demo video (outdated): https://www.youtube.com/watch?v=25nCAaqeacU
|
Demo video (outdated): https://www.youtube.com/watch?v=25nCAaqeacU
|
||||||
|
|
||||||

|

|
||||||
|
@ -44,7 +44,7 @@ local to_compress = {
|
|||||||
["default:mese_post_light"] = {
|
["default:mese_post_light"] = {
|
||||||
replace = "mese_post_light",
|
replace = "mese_post_light",
|
||||||
by = {
|
by = {
|
||||||
"mese_post_light_acacia",
|
"mese_post_light_acacia_wood",
|
||||||
"mese_post_light_aspen_wood",
|
"mese_post_light_aspen_wood",
|
||||||
"mese_post_light_junglewood",
|
"mese_post_light_junglewood",
|
||||||
"mese_post_light_pine_wood",
|
"mese_post_light_pine_wood",
|
||||||
|
@ -84,6 +84,9 @@ local styles = fmt([[
|
|||||||
style[craft_rcp,craft_usg;noclip=true;font_size=16;sound=i3_craft;
|
style[craft_rcp,craft_usg;noclip=true;font_size=16;sound=i3_craft;
|
||||||
bgimg=i3_btn9.png;bgimg_hovered=i3_btn9_hovered.png;
|
bgimg=i3_btn9.png;bgimg_hovered=i3_btn9_hovered.png;
|
||||||
bgimg_pressed=i3_btn9_pressed.png;bgimg_middle=4,6]
|
bgimg_pressed=i3_btn9_pressed.png;bgimg_middle=4,6]
|
||||||
|
style[confirm_trash_yes,confirm_trash_no;noclip=true;font_size=16;
|
||||||
|
bgimg=i3_btn9.png;bgimg_hovered=i3_btn9_hovered.png;
|
||||||
|
bgimg_pressed=i3_btn9_pressed.png;bgimg_middle=4,6]
|
||||||
]],
|
]],
|
||||||
PNG.slot,
|
PNG.slot,
|
||||||
PNG.exit, PNG.exit_hover,
|
PNG.exit, PNG.exit_hover,
|
||||||
|
267
init.lua
267
init.lua
@ -21,12 +21,10 @@ local compress_groups, compressed = loadfile(modpath .. "/etc/compress.lua")()
|
|||||||
local group_stereotypes, group_names = loadfile(modpath .. "/etc/groups.lua")()
|
local group_stereotypes, group_names = loadfile(modpath .. "/etc/groups.lua")()
|
||||||
|
|
||||||
local progressive_mode = core.settings:get_bool "i3_progressive_mode"
|
local progressive_mode = core.settings:get_bool "i3_progressive_mode"
|
||||||
local item_compression = core.settings:get_bool "i3_item_compression"
|
local item_compression = core.settings:get_bool("i3_item_compression", true)
|
||||||
local damage_enabled = core.settings:get_bool "enable_damage"
|
local damage_enabled = core.settings:get_bool "enable_damage"
|
||||||
|
|
||||||
local __3darmor, __skinsdb, __awards
|
local __3darmor, __skinsdb, __awards
|
||||||
local __sfinv, old_sfinv_fn
|
|
||||||
local __unified_inventory, old_unified_inventory_fn
|
|
||||||
|
|
||||||
local http = core.request_http_api()
|
local http = core.request_http_api()
|
||||||
local singleplayer = core.is_singleplayer()
|
local singleplayer = core.is_singleplayer()
|
||||||
@ -107,16 +105,20 @@ local function get_formspec_version(info)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function outdated(name)
|
local function outdated(name)
|
||||||
local fs = sprintf("size[5.8,1.3]image[0,0;1,1;%s]label[1,0;%s]button_exit[2.4,0.8;1,1;;OK]",
|
local fs = sprintf("size[6.3,1.3]image[0,0;1,1;%s]label[1,0;%s]button_exit[2.6,0.8;1,1;;OK]",
|
||||||
PNG.book,
|
PNG.book,
|
||||||
"Your Minetest client is outdated.\nGet the latest version on minetest.net to use i3")
|
"Your Minetest client is outdated.\nGet the latest version on minetest.net to play the game.")
|
||||||
|
|
||||||
core.show_formspec(name, "i3", fs)
|
core.show_formspec(name, "i3_outdated", fs)
|
||||||
end
|
end
|
||||||
|
|
||||||
local old_is_creative_enabled = core.is_creative_enabled
|
local old_is_creative_enabled = core.is_creative_enabled
|
||||||
|
|
||||||
function core.is_creative_enabled(name)
|
function core.is_creative_enabled(name)
|
||||||
|
if name == "" then
|
||||||
|
return old_is_creative_enabled(name)
|
||||||
|
end
|
||||||
|
|
||||||
return check_privs(name, {creative = true}) or old_is_creative_enabled(name)
|
return check_privs(name, {creative = true}) or old_is_creative_enabled(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -422,7 +424,7 @@ function i3.set_recipe_filter(name, f)
|
|||||||
recipe_filters = {[name] = f}
|
recipe_filters = {[name] = f}
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.delete_recipe_filter(name)
|
function i3.remove_recipe_filter(name)
|
||||||
recipe_filters[name] = nil
|
recipe_filters[name] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -583,6 +585,8 @@ local function search(data)
|
|||||||
local filters = {}
|
local filters = {}
|
||||||
|
|
||||||
if search_filter then
|
if search_filter then
|
||||||
|
search_filter = search_filter:trim()
|
||||||
|
|
||||||
for filter_name, values in gmatch(filter, sub(opt, 6)) do
|
for filter_name, values in gmatch(filter, sub(opt, 6)) do
|
||||||
if search_filters[filter_name] then
|
if search_filters[filter_name] then
|
||||||
values = split(values, ",")
|
values = split(values, ",")
|
||||||
@ -616,7 +620,18 @@ local function search(data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
to_add = find(search_in, filter, 1, true)
|
local ok = true
|
||||||
|
|
||||||
|
for keyword in gmatch(filter, "%S+") do
|
||||||
|
if not find(search_in, keyword, 1, true) then
|
||||||
|
ok = nil
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if ok then
|
||||||
|
to_add = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if to_add then
|
if to_add then
|
||||||
@ -723,7 +738,7 @@ local function drop_table(name, drop)
|
|||||||
if not empty and (dname ~= name or (dname == name and dcount > 1)) then
|
if not empty and (dname ~= name or (dname == name and dcount > 1)) then
|
||||||
local rarity = valid_rarity and di.rarity
|
local rarity = valid_rarity and di.rarity
|
||||||
|
|
||||||
i3.register_craft{
|
i3.register_craft {
|
||||||
type = rarity and "digging_chance" or "digging",
|
type = rarity and "digging_chance" or "digging",
|
||||||
items = {name},
|
items = {name},
|
||||||
output = fmt("%s %u", dname, dcount),
|
output = fmt("%s %u", dname, dcount),
|
||||||
@ -747,7 +762,7 @@ local function cache_drops(name, drop)
|
|||||||
local empty = dstack:is_empty()
|
local empty = dstack:is_empty()
|
||||||
|
|
||||||
if not empty and dname ~= name then
|
if not empty and dname ~= name then
|
||||||
i3.register_craft{
|
i3.register_craft {
|
||||||
type = "digging",
|
type = "digging",
|
||||||
items = {name},
|
items = {name},
|
||||||
output = drop,
|
output = drop,
|
||||||
@ -999,16 +1014,13 @@ local function spawn_item(player, stack)
|
|||||||
core.add_item(look_at, stack)
|
core.add_item(look_at, stack)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_stack(player, stack, str)
|
local function get_stack(player, stack)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local name = player:get_player_name()
|
|
||||||
|
|
||||||
if inv:room_for_item("main", stack) then
|
if inv:room_for_item("main", stack) then
|
||||||
inv:add_item("main", stack)
|
inv:add_item("main", stack)
|
||||||
msg(name, S("@1 added in your inventory", str))
|
|
||||||
else
|
else
|
||||||
spawn_item(player, stack)
|
spawn_item(player, stack)
|
||||||
msg(name, S("@1 spawned", str))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1048,22 +1060,13 @@ local function craft_stack(player, data, craft_rcp)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local count = stackcount * scrbar_val
|
local count = stackcount * scrbar_val
|
||||||
local desc = get_desc(stackname)
|
|
||||||
local iter = ceil(count / stackmax)
|
local iter = ceil(count / stackmax)
|
||||||
local leftover = count
|
local leftover = count
|
||||||
|
|
||||||
for _ = 1, iter do
|
for _ = 1, iter do
|
||||||
local c = min(stackmax, leftover)
|
local c = min(stackmax, leftover)
|
||||||
local str
|
|
||||||
|
|
||||||
if c > 1 then
|
|
||||||
str = clr("#ff0", fmt("%s x %s", c, desc))
|
|
||||||
else
|
|
||||||
str = clr("#ff0", fmt("%s", desc))
|
|
||||||
end
|
|
||||||
|
|
||||||
local stack = ItemStack(fmt("%s %s", stackname, c))
|
local stack = ItemStack(fmt("%s %s", stackname, c))
|
||||||
get_stack(player, stack, str)
|
get_stack(player, stack)
|
||||||
leftover = leftover - stackmax
|
leftover = leftover - stackmax
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1139,8 +1142,9 @@ local function select_item(player, name, data, _f)
|
|||||||
if core.is_creative_enabled(name) then
|
if core.is_creative_enabled(name) then
|
||||||
local stack = ItemStack(item)
|
local stack = ItemStack(item)
|
||||||
local stackmax = stack:get_stack_max()
|
local stackmax = stack:get_stack_max()
|
||||||
stack = fmt("%s %s", item, stackmax)
|
stack = fmt("%s %s", item, stackmax)
|
||||||
return get_stack(player, stack, clr("#ff0", fmt("%u x %s", stackmax, get_desc(item))))
|
|
||||||
|
return get_stack(player, stack)
|
||||||
end
|
end
|
||||||
|
|
||||||
if item == data.query_item then return end
|
if item == data.query_item then return end
|
||||||
@ -1374,22 +1378,34 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
|||||||
local meta = item:get_meta()
|
local meta = item:get_meta()
|
||||||
local name = item:get_name()
|
local name = item:get_name()
|
||||||
local count = item:get_count()
|
local count = item:get_count()
|
||||||
|
local X, Y
|
||||||
local X = ceil((i - 1) % width - width)
|
|
||||||
X = X + (X * 0.2) + data.inv_width + 3.9
|
|
||||||
|
|
||||||
local Y = ceil(i / width) - min(2, rows)
|
|
||||||
Y = Y + (Y * 0.15) + data.yoffset + 1.4
|
|
||||||
|
|
||||||
if large_recipe then
|
if large_recipe then
|
||||||
btn_size = (3 / width) * (3 / rows) + 0.3
|
local a, b = 3, 3
|
||||||
|
local add_x, add_y = 0, 0
|
||||||
|
|
||||||
|
if width < 3 then
|
||||||
|
a, b = width * 2, 1
|
||||||
|
add_x = 2
|
||||||
|
elseif rows < 3 then
|
||||||
|
a, b = 1, rows * 2
|
||||||
|
add_y = 1.4
|
||||||
|
end
|
||||||
|
|
||||||
|
btn_size = (a / width) * (b / rows) + 0.3
|
||||||
_btn_size = btn_size
|
_btn_size = btn_size
|
||||||
|
|
||||||
local xi = (i - 1) % width
|
local xi = (i - 1) % width
|
||||||
local yi = floor((i - 1) / width)
|
local yi = floor((i - 1) / width)
|
||||||
|
|
||||||
X = btn_size * xi + data.inv_width + 0.3 + (xi * 0.05)
|
X = btn_size * xi + data.inv_width + 0.3 + (xi * 0.05) + add_x
|
||||||
Y = btn_size * yi + data.yoffset + 0.2 + (yi * 0.05)
|
Y = btn_size * yi + data.yoffset + 0.2 + (yi * 0.05) + add_y
|
||||||
|
else
|
||||||
|
X = ceil((i - 1) % width - width)
|
||||||
|
X = X + (X * 0.2) + data.inv_width + 3.9
|
||||||
|
|
||||||
|
Y = ceil(i / width) - min(2, rows)
|
||||||
|
Y = Y + (Y * 0.15) + data.yoffset + 1.4
|
||||||
end
|
end
|
||||||
|
|
||||||
if X > right then
|
if X > right then
|
||||||
@ -1535,7 +1551,7 @@ local function get_model_fs(fs, data, def, model_alias)
|
|||||||
_name = fmt("%s^[multiply:%s", v.name, v.color)
|
_name = fmt("%s^[multiply:%s", v.name, v.color)
|
||||||
end
|
end
|
||||||
elseif v.animation then
|
elseif v.animation then
|
||||||
_name = fmt("%s^[verticalframe:%u:0", v.name, v.animation.aspect_h)
|
_name = fmt("%s^[verticalframe:%u:0", v.name, v.animation.frames_h or v.animation.aspect_h)
|
||||||
end
|
end
|
||||||
|
|
||||||
t[#t + 1] = _name or v.name or v
|
t[#t + 1] = _name or v.name or v
|
||||||
@ -1691,7 +1707,7 @@ local function get_items_fs(fs, data, full_height)
|
|||||||
data.items = new
|
data.items = new
|
||||||
end
|
end
|
||||||
|
|
||||||
local items = data.alt_items or data.items
|
local items = data.alt_items or data.items or {}
|
||||||
local rows, lines = 8, 12
|
local rows, lines = 8, 12
|
||||||
local ipp = rows * lines
|
local ipp = rows * lines
|
||||||
local size = 0.85
|
local size = 0.85
|
||||||
@ -2038,16 +2054,21 @@ local function get_ctn_content(fs, data, player, yoffset, ctn_len, award_list, a
|
|||||||
elseif data.subcat == 3 then
|
elseif data.subcat == 3 then
|
||||||
if __skinsdb then
|
if __skinsdb then
|
||||||
local _skins = skins.get_skinlist_for_player(name)
|
local _skins = skins.get_skinlist_for_player(name)
|
||||||
local sks = {}
|
local skin_name = skins.get_player_skin(player).name
|
||||||
|
local sks, id = {}, 1
|
||||||
|
|
||||||
|
for i, skin in ipairs(_skins) do
|
||||||
|
if skin.name == skin_name then
|
||||||
|
id = i
|
||||||
|
end
|
||||||
|
|
||||||
for _, skin in ipairs(_skins) do
|
|
||||||
sks[#sks + 1] = skin.name
|
sks[#sks + 1] = skin.name
|
||||||
end
|
end
|
||||||
|
|
||||||
sks = concat(sks, ","):gsub(";", "")
|
sks = concat(sks, ","):gsub(";", "")
|
||||||
|
|
||||||
fs("label", 0, yextra + 0.85, fmt("%s:", ES"Select a skin"))
|
fs("label", 0, yextra + 0.85, fmt("%s:", ES"Select a skin"))
|
||||||
fs(fmt("dropdown[0,%f;4,0.6;skins;%s;%u;true]", yextra + 1.1, sks, data.skin_id or 1))
|
fs(fmt("dropdown[0,%f;4,0.6;skins;%s;%u;true]", yextra + 1.1, sks, id))
|
||||||
else
|
else
|
||||||
not_installed("skinsdb")
|
not_installed("skinsdb")
|
||||||
end
|
end
|
||||||
@ -2115,18 +2136,26 @@ local function get_tabs_fs(player, data, fs, full_height)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_debug_grid(data, fs, full_height)
|
local function get_debug_grid(data, fs, full_height)
|
||||||
local spacing = 0.2
|
fs("style_type[label;font_size=8;noclip=true]")
|
||||||
|
local spacing, i = 0.2, 1
|
||||||
|
|
||||||
for x = 0, data.inv_width + 8, spacing do
|
for x = 0, data.inv_width + 8, spacing do
|
||||||
fs("box", x, 0, 0.01, full_height, "#ff0")
|
fs("box", x, 0, 0.01, full_height, "#ff0")
|
||||||
|
fs("label", x, full_height + 0.1, tostring(i))
|
||||||
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
i = 61
|
||||||
|
|
||||||
for y = 0, full_height, spacing do
|
for y = 0, full_height, spacing do
|
||||||
fs("box", 0, y, data.inv_width + 8, 0.01, "#ff0")
|
fs("box", 0, y, data.inv_width + 8, 0.01, "#ff0")
|
||||||
|
fs("label", -0.15, y, tostring(i))
|
||||||
|
i = i - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
fs("box", data.inv_width / 2, 0, 0.01, full_height, "#f00")
|
fs("box", data.inv_width / 2, 0, 0.01, full_height, "#f00")
|
||||||
fs("box", 0, full_height / 2, data.inv_width, 0.01, "#f00")
|
fs("box", 0, full_height / 2, data.inv_width, 0.01, "#f00")
|
||||||
|
fs("style_type[label;font_size=16]")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function make_fs(player, data)
|
local function make_fs(player, data)
|
||||||
@ -2207,9 +2236,9 @@ function i3.get_tabs()
|
|||||||
return tabs
|
return tabs
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.delete_tab(tabname)
|
function i3.remove_tab(tabname)
|
||||||
if not true_str(tabname) then
|
if not true_str(tabname) then
|
||||||
return err "i3.delete_tab: tab name missing"
|
return err "i3.remove_tab: tab name missing"
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, def in ipairs(tabs) do
|
for i, def in ipairs(tabs) do
|
||||||
@ -2219,6 +2248,13 @@ function i3.delete_tab(tabname)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function i3.get_current_tab(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
local data = pdata[name]
|
||||||
|
|
||||||
|
return data.current_tab
|
||||||
|
end
|
||||||
|
|
||||||
function i3.set_tab(player, tabname)
|
function i3.set_tab(player, tabname)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
@ -2286,20 +2322,21 @@ local function init_data(player, info)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function reset_data(data)
|
local function reset_data(data)
|
||||||
data.filter = ""
|
data.filter = ""
|
||||||
data.expand = ""
|
data.expand = ""
|
||||||
data.pagenum = 1
|
data.pagenum = 1
|
||||||
data.rnum = 1
|
data.rnum = 1
|
||||||
data.unum = 1
|
data.unum = 1
|
||||||
data.scrbar_rcp = 1
|
data.scrbar_rcp = 1
|
||||||
data.scrbar_usg = 1
|
data.scrbar_usg = 1
|
||||||
data.query_item = nil
|
data.query_item = nil
|
||||||
data.recipes = nil
|
data.recipes = nil
|
||||||
data.usages = nil
|
data.usages = nil
|
||||||
data.export_rcp = nil
|
data.export_rcp = nil
|
||||||
data.export_usg = nil
|
data.export_usg = nil
|
||||||
data.alt_items = nil
|
data.alt_items = nil
|
||||||
data.items = data.items_raw
|
data.confirm_trash = nil
|
||||||
|
data.items = data.items_raw
|
||||||
|
|
||||||
if data.current_itab > 1 then
|
if data.current_itab > 1 then
|
||||||
sort_by_category(data)
|
sort_by_category(data)
|
||||||
@ -2387,6 +2424,14 @@ local function rcp_fields(player, data, fields)
|
|||||||
|
|
||||||
elseif fields.craft_rcp or fields.craft_usg then
|
elseif fields.craft_rcp or fields.craft_usg then
|
||||||
craft_stack(player, data, fields.craft_rcp)
|
craft_stack(player, data, fields.craft_rcp)
|
||||||
|
|
||||||
|
if fields.craft_rcp then
|
||||||
|
data.export_rcp = nil
|
||||||
|
data.scrbar_rcp = 1
|
||||||
|
else
|
||||||
|
data.export_usg = nil
|
||||||
|
data.scrbar_usg = 1
|
||||||
|
end
|
||||||
else
|
else
|
||||||
select_item(player, name, data, fields)
|
select_item(player, name, data, fields)
|
||||||
end
|
end
|
||||||
@ -2501,7 +2546,7 @@ local function get_inventory_fs(player, data, fs)
|
|||||||
fs("scroll_container_end[]")
|
fs("scroll_container_end[]")
|
||||||
|
|
||||||
local btn = {
|
local btn = {
|
||||||
{"trash", ES"Trash all items"},
|
{"trash", ES"Clear inventory"},
|
||||||
{"sort_az", ES"Sort items (A-Z)"},
|
{"sort_az", ES"Sort items (A-Z)"},
|
||||||
{"sort_za", ES"Sort items (Z-A)"},
|
{"sort_za", ES"Sort items (Z-A)"},
|
||||||
{"compress", ES"Compress items"},
|
{"compress", ES"Compress items"},
|
||||||
@ -2516,6 +2561,18 @@ local function get_inventory_fs(player, data, fs)
|
|||||||
fs("image_button", i + 3.447 - (i * 0.4), 11.43, 0.35, 0.35, "", btn_name, "")
|
fs("image_button", i + 3.447 - (i * 0.4), 11.43, 0.35, 0.35, "", btn_name, "")
|
||||||
fs(fmt("tooltip[%s;%s]", btn_name, tooltip))
|
fs(fmt("tooltip[%s;%s]", btn_name, tooltip))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if data.confirm_trash then
|
||||||
|
fs("style_type[box;colors=#999,#999,#808080,#808080]")
|
||||||
|
|
||||||
|
for _ = 1, 3 do
|
||||||
|
fs("box", 2.97, 10.75, 4.3, 0.5, "")
|
||||||
|
end
|
||||||
|
|
||||||
|
fs("label", 3.12, 11, "Confirm trash?")
|
||||||
|
fs("image_button", 5.17, 10.75, 1, 0.5, "", "confirm_trash_yes", "Yes")
|
||||||
|
fs("image_button", 6.27, 10.75, 1, 0.5, "", "confirm_trash_no", "No")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
i3.new_tab {
|
i3.new_tab {
|
||||||
@ -2527,10 +2584,10 @@ i3.new_tab {
|
|||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local sb_inv = fields.scrbar_inv
|
local sb_inv = fields.scrbar_inv
|
||||||
|
|
||||||
if fields.skins and data.skin_id ~= tonum(fields.skins) then
|
if fields.skins then
|
||||||
data.skin_id = tonum(fields.skins)
|
local id = tonum(fields.skins)
|
||||||
local _skins = skins.get_skinlist_for_player(name)
|
local _skins = skins.get_skinlist_for_player(name)
|
||||||
skins.set_player_skin(player, _skins[data.skin_id])
|
skins.set_player_skin(player, _skins[id])
|
||||||
end
|
end
|
||||||
|
|
||||||
for field in pairs(fields) do
|
for field in pairs(fields) do
|
||||||
@ -2587,9 +2644,16 @@ i3.new_tab {
|
|||||||
end
|
end
|
||||||
|
|
||||||
if fields.trash then
|
if fields.trash then
|
||||||
local inv = player:get_inventory()
|
data.confirm_trash = true
|
||||||
inv:set_list("main", {})
|
|
||||||
inv:set_list("craft", {})
|
elseif fields.confirm_trash_yes or fields.confirm_trash_no then
|
||||||
|
if fields.confirm_trash_yes then
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
inv:set_list("main", {})
|
||||||
|
inv:set_list("craft", {})
|
||||||
|
end
|
||||||
|
|
||||||
|
data.confirm_trash = nil
|
||||||
|
|
||||||
elseif fields.compress then
|
elseif fields.compress then
|
||||||
compress_items(player)
|
compress_items(player)
|
||||||
@ -2697,8 +2761,6 @@ if rawget(_G, "awards") then
|
|||||||
local player = core.get_player_by_name(name)
|
local player = core.get_player_by_name(name)
|
||||||
set_fs(player)
|
set_fs(player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
core.register_on_dieplayer(set_fs)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
core.register_on_chatcommand(function(name)
|
core.register_on_chatcommand(function(name)
|
||||||
@ -2870,18 +2932,12 @@ end
|
|||||||
core.register_on_mods_loaded(function()
|
core.register_on_mods_loaded(function()
|
||||||
get_init_items()
|
get_init_items()
|
||||||
|
|
||||||
__sfinv = rawget(_G, "sfinv")
|
if rawget(_G, "sfinv") then
|
||||||
|
|
||||||
if __sfinv then
|
|
||||||
old_sfinv_fn = sfinv.set_player_inventory_formspec
|
|
||||||
function sfinv.set_player_inventory_formspec() return end
|
function sfinv.set_player_inventory_formspec() return end
|
||||||
sfinv.enabled = false
|
sfinv.enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
__unified_inventory = rawget(_G, "unified_inventory")
|
if rawget(_G, "unified_inventory") then
|
||||||
|
|
||||||
if __unified_inventory then
|
|
||||||
old_unified_inventory_fn = unified_inventory.set_inventory_formspec
|
|
||||||
function unified_inventory.set_inventory_formspec() return end
|
function unified_inventory.set_inventory_formspec() return end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@ -2961,21 +3017,7 @@ core.register_on_joinplayer(function(player)
|
|||||||
local info = core.get_player_information and core.get_player_information(name)
|
local info = core.get_player_information and core.get_player_information(name)
|
||||||
|
|
||||||
if not info or get_formspec_version(info) < MIN_FORMSPEC_VERSION then
|
if not info or get_formspec_version(info) < MIN_FORMSPEC_VERSION then
|
||||||
if __sfinv then
|
|
||||||
sfinv.set_player_inventory_formspec = old_sfinv_fn
|
|
||||||
sfinv.enabled = true
|
|
||||||
end
|
|
||||||
|
|
||||||
if __unified_inventory then
|
|
||||||
unified_inventory.set_inventory_formspec = old_unified_inventory_fn
|
|
||||||
|
|
||||||
if __sfinv then
|
|
||||||
sfinv.enabled = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
pdata[name] = nil
|
pdata[name] = nil
|
||||||
|
|
||||||
return outdated(name)
|
return outdated(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2994,11 +3036,13 @@ core.register_on_dieplayer(function(player)
|
|||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
data.bag_size = nil
|
if data.bag_size then
|
||||||
data.bag:set_list("main", {})
|
data.bag_size = nil
|
||||||
|
data.bag:set_list("main", {})
|
||||||
|
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
inv:set_size("main", INV_SIZE)
|
inv:set_size("main", INV_SIZE)
|
||||||
|
end
|
||||||
|
|
||||||
set_fs(player)
|
set_fs(player)
|
||||||
end)
|
end)
|
||||||
@ -3006,7 +3050,6 @@ end)
|
|||||||
local META_SAVES = {
|
local META_SAVES = {
|
||||||
bag_size = true,
|
bag_size = true,
|
||||||
waypoints = true,
|
waypoints = true,
|
||||||
skin_id = true,
|
|
||||||
inv_items = true,
|
inv_items = true,
|
||||||
known_recipes = true,
|
known_recipes = true,
|
||||||
}
|
}
|
||||||
@ -3019,7 +3062,7 @@ local function save_data(player_name)
|
|||||||
if not META_SAVES[dat] then
|
if not META_SAVES[dat] then
|
||||||
_pdata[name][dat] = nil
|
_pdata[name][dat] = nil
|
||||||
|
|
||||||
if player_name then
|
if player_name and pdata[player_name] then
|
||||||
pdata[player_name][dat] = nil -- To free up some memory
|
pdata[player_name][dat] = nil -- To free up some memory
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3044,11 +3087,14 @@ end
|
|||||||
after(SAVE_INTERVAL, routine)
|
after(SAVE_INTERVAL, routine)
|
||||||
|
|
||||||
core.register_on_player_receive_fields(function(player, formname, fields)
|
core.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if formname ~= "" then
|
local name = player:get_player_name()
|
||||||
|
|
||||||
|
if formname == "i3_outdated" then
|
||||||
|
return false, core.kick_player(name, "Come back when your client is up-to-date.")
|
||||||
|
elseif formname ~= "" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
if not data then return end
|
if not data then return end
|
||||||
|
|
||||||
@ -3199,6 +3245,7 @@ if progressive_mode then
|
|||||||
number = 0xffffff,
|
number = 0xffffff,
|
||||||
text = "",
|
text = "",
|
||||||
z_index = 0xDEAD,
|
z_index = 0xDEAD,
|
||||||
|
style = 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -3226,7 +3273,8 @@ if progressive_mode then
|
|||||||
end
|
end
|
||||||
|
|
||||||
player:hud_change(data.hud.text, "text",
|
player:hud_change(data.hud.text, "text",
|
||||||
S("@1 new recipe(s) discovered!", data.discovered))
|
fmt("%u new recipe%s unlocked!",
|
||||||
|
data.discovered, data.discovered > 1 and "s" or ""))
|
||||||
|
|
||||||
elseif data.show_hud == false then
|
elseif data.show_hud == false then
|
||||||
if data.hud_timer >= HUD_TIMER_MAX then
|
if data.hud_timer >= HUD_TIMER_MAX then
|
||||||
@ -3256,6 +3304,7 @@ if progressive_mode then
|
|||||||
local player = players[i]
|
local player = players[i]
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
|
if not data then return end
|
||||||
|
|
||||||
local inv_items = get_inv_items(player)
|
local inv_items = get_inv_items(player)
|
||||||
local diff = array_diff(inv_items, data.inv_items)
|
local diff = array_diff(inv_items, data.inv_items)
|
||||||
@ -3283,35 +3332,41 @@ if progressive_mode then
|
|||||||
|
|
||||||
poll_new_items()
|
poll_new_items()
|
||||||
|
|
||||||
core.register_globalstep(function()
|
if singleplayer then
|
||||||
local players = core.get_connected_players()
|
core.register_globalstep(function()
|
||||||
|
local name = "singleplayer"
|
||||||
for i = 1, #players do
|
local player = core.get_player_by_name(name)
|
||||||
local player = players[i]
|
|
||||||
local name = player:get_player_name()
|
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
|
|
||||||
if data.show_hud ~= nil and singleplayer then
|
if data and data.show_hud ~= nil then
|
||||||
show_hud_success(player, data)
|
show_hud_success(player, data)
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
end)
|
end
|
||||||
|
|
||||||
i3.add_recipe_filter("Default progressive filter", progressive_filter)
|
i3.add_recipe_filter("Default progressive filter", progressive_filter)
|
||||||
|
|
||||||
core.register_on_joinplayer(function(player)
|
core.register_on_joinplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = pdata[name]
|
local data = pdata[name]
|
||||||
|
if not data then return end
|
||||||
|
|
||||||
data.inv_items = data.inv_items or {}
|
data.inv_items = data.inv_items or {}
|
||||||
data.known_recipes = data.known_recipes or 0
|
data.known_recipes = data.known_recipes or 0
|
||||||
|
|
||||||
|
local oldknown = data.known_recipes
|
||||||
local items = get_filtered_items(player, data)
|
local items = get_filtered_items(player, data)
|
||||||
|
data.discovered = data.known_recipes - oldknown
|
||||||
|
|
||||||
data.items_raw = items
|
data.items_raw = items
|
||||||
search(data)
|
search(data)
|
||||||
|
|
||||||
if singleplayer then
|
if singleplayer then
|
||||||
init_hud(player, data)
|
init_hud(player, data)
|
||||||
|
|
||||||
|
if data.show_hud == nil and data.discovered > 0 then
|
||||||
|
data.show_hud = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -20,6 +20,139 @@ i3.register_craft({
|
|||||||
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({
|
||||||
|
grid = {
|
||||||
|
"X",
|
||||||
|
"#",
|
||||||
|
"X",
|
||||||
|
"X",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
|
i3.register_craft({
|
||||||
|
grid = {
|
||||||
|
"X",
|
||||||
|
"#X",
|
||||||
|
"X",
|
||||||
|
"X",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
|
i3.register_craft({
|
||||||
|
grid = {
|
||||||
|
"X",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
i3.register_craft({
|
||||||
|
grid = {
|
||||||
|
"X#",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
|
i3.register_craft({
|
||||||
|
grid = {
|
||||||
|
"X#X",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
|
i3.register_craft({
|
||||||
|
grid = {
|
||||||
|
"X#XX",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
|
i3.register_craft({
|
||||||
|
grid = {
|
||||||
|
"X#XX",
|
||||||
|
"X#X",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
|
i3.register_craft({
|
||||||
|
grid = {
|
||||||
|
"X#XX",
|
||||||
|
"X#X",
|
||||||
|
"#",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
|
i3.register_craft({
|
||||||
|
grid = {
|
||||||
|
"X##XX",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
|
i3.register_craft({
|
||||||
|
grid = {
|
||||||
|
"X##X#X",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
|
i3.register_craft({
|
||||||
|
grid = {
|
||||||
|
"X##X#X",
|
||||||
|
"",
|
||||||
|
"X",
|
||||||
|
},
|
||||||
|
key = {
|
||||||
|
['#'] = "default:wood",
|
||||||
|
['X'] = "default:glass 2",
|
||||||
|
},
|
||||||
|
result = "default:mese 3",
|
||||||
|
})
|
||||||
|
|
||||||
i3.register_craft({
|
i3.register_craft({
|
||||||
grid = {
|
grid = {
|
||||||
"X #",
|
"X #",
|
||||||
|
Reference in New Issue
Block a user