mirror of
https://github.com/minetest-mods/i3.git
synced 2025-07-03 09:00:23 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
612bdc86d1 | |||
03968b70c5 | |||
10629aeb89 | |||
551a9d517d | |||
bcca6f00be | |||
2fcd559261 | |||
cffdf77e6a | |||
cacb9a29fd | |||
382ff397a5 |
@ -1,4 +1,4 @@
|
|||||||
# i3
|

|
||||||
|
|
||||||
[](https://github.com/tterb/atomic-design-ui/blob/master/LICENSEs) []() [](https://content.minetest.net/packages/jp/i3/) [](https://www.paypal.me/jpg84240)
|
[](https://github.com/tterb/atomic-design-ui/blob/master/LICENSEs) []() [](https://content.minetest.net/packages/jp/i3/) [](https://www.paypal.me/jpg84240)
|
||||||
|
|
||||||
|
29
init.lua
29
init.lua
@ -1,17 +1,26 @@
|
|||||||
|
print[[
|
||||||
|
|
||||||
|
Powered by
|
||||||
|
|
||||||
|
██╗██████╗
|
||||||
|
██║╚════██╗
|
||||||
|
██║ █████╔╝
|
||||||
|
██║ ╚═══██╗
|
||||||
|
██║██████╔╝
|
||||||
|
╚═╝╚═════╝
|
||||||
|
]]
|
||||||
|
|
||||||
local modpath = core.get_modpath"i3"
|
local modpath = core.get_modpath"i3"
|
||||||
|
local http = core.request_http_api()
|
||||||
local _loadfile = dofile(modpath .. "/src/operators.lua")
|
local _loadfile = dofile(modpath .. "/src/operators.lua")
|
||||||
|
|
||||||
local function lf(path)
|
local function lf(path)
|
||||||
return _loadfile(modpath .. path)
|
return assert(_loadfile(modpath .. path))
|
||||||
end
|
end
|
||||||
|
|
||||||
i3 = {
|
i3 = {
|
||||||
modules = {},
|
modules = {},
|
||||||
http = core.request_http_api(),
|
|
||||||
|
|
||||||
MAX_FAVS = 6,
|
MAX_FAVS = 6,
|
||||||
INV_SIZE = 4*9,
|
|
||||||
HOTBAR_LEN = 9,
|
|
||||||
ITEM_BTN_SIZE = 1.1,
|
ITEM_BTN_SIZE = 1.1,
|
||||||
DROP_BAG_ON_DIE = true,
|
DROP_BAG_ON_DIE = true,
|
||||||
MIN_FORMSPEC_VERSION = 4,
|
MIN_FORMSPEC_VERSION = 4,
|
||||||
@ -76,11 +85,15 @@ i3 = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
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),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i3.HOTBAR_LEN = i3.legacy_inventory and 8 or 9
|
||||||
|
i3.INV_SIZE = 4 * i3.HOTBAR_LEN
|
||||||
|
|
||||||
i3.files.common()
|
i3.files.common()
|
||||||
i3.files.api()
|
i3.files.api(http)
|
||||||
i3.files.compress()
|
i3.files.compress()
|
||||||
i3.files.groups()
|
i3.files.groups()
|
||||||
i3.files.callbacks()
|
i3.files.callbacks()
|
||||||
@ -93,7 +106,7 @@ i3.data = dslz(storage:get_string"data") or {}
|
|||||||
|
|
||||||
local init_bags = i3.files.bags()
|
local init_bags = i3.files.bags()
|
||||||
local init_detached = i3.files.detached()
|
local init_detached = i3.files.detached()
|
||||||
local fill_caches = i3.files.caches()
|
local fill_caches = i3.files.caches(http)
|
||||||
local init_hud = i3.files.hud()
|
local init_hud = i3.files.hud()
|
||||||
|
|
||||||
local function get_lang_code(info)
|
local function get_lang_code(info)
|
||||||
@ -241,4 +254,4 @@ end
|
|||||||
--i3.files.tests.tabs()
|
--i3.files.tests.tabs()
|
||||||
--i3.files.tests.operators()
|
--i3.files.tests.operators()
|
||||||
--i3.files.tests.compression()
|
--i3.files.tests.compression()
|
||||||
--i3.files.tests.custom_recipes()
|
--i3.files.tests.custom_recipes(http)
|
||||||
|
@ -2,4 +2,7 @@
|
|||||||
i3_progressive_mode (Learn crafting recipes progressively) bool false
|
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
|
18
src/api.lua
18
src/api.lua
@ -1,4 +1,5 @@
|
|||||||
local make_fs = i3.files.gui()
|
local make_fs = i3.files.gui()
|
||||||
|
local http = ...
|
||||||
|
|
||||||
IMPORT("gmatch", "split")
|
IMPORT("gmatch", "split")
|
||||||
IMPORT("S", "err", "fmt", "reg_items")
|
IMPORT("S", "err", "fmt", "reg_items")
|
||||||
@ -22,13 +23,7 @@ function i3.register_craft(def)
|
|||||||
local width, c = 0, 0
|
local width, c = 0, 0
|
||||||
|
|
||||||
if true_str(def.url) then
|
if true_str(def.url) then
|
||||||
if not i3.http then
|
http.fetch({url = def.url}, function(result)
|
||||||
return err(fmt([[i3.register_craft(): Unable to reach %s.
|
|
||||||
No HTTP support for this mod: add it to the `secure.http_mods` or
|
|
||||||
`secure.trusted_mods` setting.]], def.url))
|
|
||||||
end
|
|
||||||
|
|
||||||
i3.http.fetch({url = def.url}, function(result)
|
|
||||||
if result.succeeded then
|
if result.succeeded then
|
||||||
local t = core.parse_json(result.data)
|
local t = core.parse_json(result.data)
|
||||||
if is_table(t) then
|
if is_table(t) then
|
||||||
@ -154,10 +149,11 @@ function i3.add_search_filter(name, f)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function i3.get_recipes(item)
|
function i3.get_recipes(item)
|
||||||
return {
|
item = core.registered_aliases[item] or item
|
||||||
recipes = i3.recipes_cache[item],
|
local recipes = i3.recipes_cache[item]
|
||||||
usages = i3.usages_cache[item]
|
local usages = i3.usages_cache[item]
|
||||||
}
|
|
||||||
|
return {recipes = recipes, usages = usages}
|
||||||
end
|
end
|
||||||
|
|
||||||
function i3.set_fs(player)
|
function i3.set_fs(player)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
local replacements = {fuel = {}}
|
local replacements = {fuel = {}}
|
||||||
|
local http = ...
|
||||||
|
|
||||||
IMPORT("maxn", "copy", "insert", "sort", "match", "sub")
|
IMPORT("maxn", "copy", "insert", "sort", "match", "sub")
|
||||||
IMPORT("is_group", "extract_groups", "item_has_groups", "groups_to_items")
|
IMPORT("is_group", "extract_groups", "item_has_groups", "groups_to_items")
|
||||||
@ -269,13 +270,13 @@ local function init_recipes()
|
|||||||
resolve_aliases(_select)
|
resolve_aliases(_select)
|
||||||
sort(i3.init_items)
|
sort(i3.init_items)
|
||||||
|
|
||||||
if i3.http and true_str(i3.export_url) then
|
if http and true_str(i3.export_url) then
|
||||||
local post_data = {
|
local post_data = {
|
||||||
recipes = i3.recipes_cache,
|
recipes = i3.recipes_cache,
|
||||||
usages = i3.usages_cache,
|
usages = i3.usages_cache,
|
||||||
}
|
}
|
||||||
|
|
||||||
i3.http.fetch_async {
|
http.fetch_async {
|
||||||
url = i3.export_url,
|
url = i3.export_url,
|
||||||
post_data = core.write_json(post_data),
|
post_data = core.write_json(post_data),
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
local ItemStack = ItemStack
|
local ItemStack = ItemStack
|
||||||
local loadstring = loadstring
|
local loadstring = loadstring
|
||||||
|
local reg_items = core.registered_items
|
||||||
local translate = core.get_translated_string
|
local translate = core.get_translated_string
|
||||||
local vec_new, vec_add, vec_mul = vector.new, vector.add, vector.multiply
|
local vec_new, vec_add, vec_mul = vector.new, vector.add, vector.multiply
|
||||||
local sort, concat, insert = table.sort, table.concat, table.insert
|
local sort, concat, insert = table.sort, table.concat, table.insert
|
||||||
@ -99,7 +100,7 @@ local function search(data)
|
|||||||
|
|
||||||
for i = 1, #data.items_raw do
|
for i = 1, #data.items_raw do
|
||||||
local item = data.items_raw[i]
|
local item = data.items_raw[i]
|
||||||
local def = core.registered_items[item]
|
local def = reg_items[item]
|
||||||
local desc = lower(translate(data.lang_code, def and def.description)) or ""
|
local desc = lower(translate(data.lang_code, def and def.description)) or ""
|
||||||
local search_in = fmt("%s %s", item, desc)
|
local search_in = fmt("%s %s", item, desc)
|
||||||
local temp, j, to_add = {}, 1
|
local temp, j, to_add = {}, 1
|
||||||
@ -250,7 +251,7 @@ local function groups_to_items(groups, get_all)
|
|||||||
if not get_all and #groups == 1 then
|
if not get_all and #groups == 1 then
|
||||||
local group = groups[1]
|
local group = groups[1]
|
||||||
local stereotype = i3.group_stereotypes[group]
|
local stereotype = i3.group_stereotypes[group]
|
||||||
local def = core.registered_items[stereotype]
|
local def = reg_items[stereotype]
|
||||||
|
|
||||||
if valid_item(def) then
|
if valid_item(def) then
|
||||||
return stereotype
|
return stereotype
|
||||||
@ -259,7 +260,7 @@ local function groups_to_items(groups, get_all)
|
|||||||
|
|
||||||
local names = {}
|
local names = {}
|
||||||
|
|
||||||
for name, def in pairs(core.registered_items) do
|
for name, def in pairs(reg_items) do
|
||||||
if valid_item(def) and item_has_groups(def.groups, groups) then
|
if valid_item(def) and item_has_groups(def.groups, groups) then
|
||||||
if get_all then
|
if get_all then
|
||||||
insert(names, name)
|
insert(names, name)
|
||||||
@ -340,9 +341,9 @@ local function spawn_item(player, stack)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_recipes(player, item)
|
local function get_recipes(player, item)
|
||||||
local clean_item = core.registered_aliases[item] or item
|
item = core.registered_aliases[item] or item
|
||||||
local recipes = i3.recipes_cache[clean_item]
|
local recipes = i3.recipes_cache[item]
|
||||||
local usages = i3.usages_cache[clean_item]
|
local usages = i3.usages_cache[item]
|
||||||
|
|
||||||
if recipes then
|
if recipes then
|
||||||
recipes = apply_recipe_filters(recipes, player)
|
recipes = apply_recipe_filters(recipes, player)
|
||||||
@ -351,7 +352,6 @@ local function get_recipes(player, item)
|
|||||||
local no_recipes = not recipes or #recipes == 0
|
local no_recipes = not recipes or #recipes == 0
|
||||||
if no_recipes and not usages then return end
|
if no_recipes and not usages then return end
|
||||||
usages = apply_recipe_filters(usages, player)
|
usages = apply_recipe_filters(usages, player)
|
||||||
|
|
||||||
local no_usages = not usages or #usages == 0
|
local no_usages = not usages or #usages == 0
|
||||||
|
|
||||||
return not no_recipes and recipes or nil,
|
return not no_recipes and recipes or nil,
|
||||||
@ -539,7 +539,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 10 or 1
|
local start_i = data.ignore_hotbar and (i3.HOTBAR_LEN + 1) or 1
|
||||||
|
|
||||||
if true_table(data.drop_items) then
|
if true_table(data.drop_items) then
|
||||||
list = drop_items(player, inv, list, start_i, data.drop_items)
|
list = drop_items(player, inv, list, start_i, data.drop_items)
|
||||||
@ -584,6 +584,7 @@ local function get_detached_inv(name, player_name)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Much faster implementation of `unpack`
|
||||||
local function createunpack(n)
|
local function createunpack(n)
|
||||||
local ret = {"local t = ... return "}
|
local ret = {"local t = ... return "}
|
||||||
|
|
||||||
|
140
src/gui.lua
140
src/gui.lua
@ -16,7 +16,7 @@ IMPORT("S", "ES", "translate", "ItemStack", "toupper")
|
|||||||
IMPORT("groups_to_items", "compression_active", "compressible")
|
IMPORT("groups_to_items", "compression_active", "compressible")
|
||||||
IMPORT("true_str", "is_fav", "is_num", "get_group", "str_to_pos")
|
IMPORT("true_str", "is_fav", "is_num", "get_group", "str_to_pos")
|
||||||
IMPORT("maxn", "sort", "concat", "copy", "insert", "remove", "unpack")
|
IMPORT("maxn", "sort", "concat", "copy", "insert", "remove", "unpack")
|
||||||
IMPORT("get_sorting_idx", "is_group", "extract_groups", "item_has_groups")
|
IMPORT("get_sorting_idx", "is_group", "extract_groups", "item_has_groups", "get_recipes")
|
||||||
|
|
||||||
local function fmt(elem, ...)
|
local function fmt(elem, ...)
|
||||||
if not fs_elements[elem] then
|
if not fs_elements[elem] then
|
||||||
@ -122,7 +122,9 @@ local function get_stack_max(inv, data, is_recipe, rcp)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_inv_slots(fs)
|
local function get_inv_slots(fs)
|
||||||
local inv_x, inv_y, size, spacing = 0.22, 6.9, 1, 0.1
|
local inv_x = i3.legacy_inventory and 0.75 or 0.22
|
||||||
|
local inv_y = 6.9
|
||||||
|
local size, spacing = 1, 0.1
|
||||||
|
|
||||||
fs"style_type[box;colors=#77777710,#77777710,#777,#777]"
|
fs"style_type[box;colors=#77777710,#77777710,#777,#777]"
|
||||||
|
|
||||||
@ -219,13 +221,23 @@ local function get_award_list(data, fs, ctn_len, yextra, award_list, awards_unlo
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_isometric_view(fs, pos, X, Y)
|
local function get_isometric_view(fs, pos, X, Y, t, cubes, depth, high)
|
||||||
pos = vec_round(pos)
|
pos = vec_round(pos)
|
||||||
local width = 8
|
cubes = cubes or 0
|
||||||
|
depth = depth or -1
|
||||||
|
high = high or math.huge
|
||||||
|
|
||||||
local pos1 = vec_new(pos.x - width, pos.y - 1, pos.z - width)
|
t = t or {}
|
||||||
local pos2 = vec_new(pos.x + width, pos.y + 3, pos.z + width)
|
t[depth] = {}
|
||||||
core.emerge_area(pos1, pos2)
|
|
||||||
|
local width = 8
|
||||||
|
local base_height = 4
|
||||||
|
local base_depth = depth == -1
|
||||||
|
local max_depth = -5
|
||||||
|
local height = base_depth and (base_height - 1) or depth
|
||||||
|
|
||||||
|
local pos1 = vec_new(pos.x - width, pos.y + depth, pos.z - width)
|
||||||
|
local pos2 = vec_new(pos.x + width, pos.y + height, pos.z + width)
|
||||||
|
|
||||||
local vm = VoxelManip(pos1, pos2)
|
local vm = VoxelManip(pos1, pos2)
|
||||||
local emin, emax = vm:read_from_map(pos1, pos2)
|
local emin, emax = vm:read_from_map(pos1, pos2)
|
||||||
@ -243,15 +255,45 @@ local function get_isometric_view(fs, pos, X, Y)
|
|||||||
|
|
||||||
local size = 0.25
|
local size = 0.25
|
||||||
local x = 2 + (size / 2 * (p.z - p.x))
|
local x = 2 + (size / 2 * (p.z - p.x))
|
||||||
local y = 1.15 + (size / 4 * (p.x + p.z - 2 * p.y))
|
local y = 1 + (size / 4 * (p.x + p.z - 2 * p.y))
|
||||||
|
|
||||||
|
if y < high then
|
||||||
|
high = y
|
||||||
|
end
|
||||||
|
|
||||||
if plant then
|
if plant then
|
||||||
size -= 0.05
|
size -= 0.05
|
||||||
end
|
end
|
||||||
|
|
||||||
insert(fs, fmt("image[%f,%f;%.1f,%.1f;%s]", x + X, y + Y, size, size, img))
|
cubes++
|
||||||
|
insert(t[depth], {x + X, y + Y, size, size, img})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local maxc = ((width << 1) ^ 2) * base_height
|
||||||
|
|
||||||
|
if cubes < maxc and depth > max_depth then
|
||||||
|
-- if there's not enough map to preview, go deeper
|
||||||
|
depth -= 1
|
||||||
|
get_isometric_view(fs, pos, X, Y, t, cubes, depth, high)
|
||||||
|
else
|
||||||
|
local shift = -0.3 - high
|
||||||
|
|
||||||
|
for i = max_depth, 0 do
|
||||||
|
local dth = t[i]
|
||||||
|
if dth then
|
||||||
|
dth[0] = #dth
|
||||||
|
for j = 1, dth[0] do
|
||||||
|
local params = dth[j]
|
||||||
|
params[2] += shift
|
||||||
|
insert(fs, fmt("image[%f,%f;%.1f,%.1f;%s]", unpack(params)))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
shift += (base_depth and 0.45 or 0.95)
|
||||||
|
fs("image", 2.7, Y + shift, 0.3, 0.3, PNG.flag)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
||||||
@ -262,6 +304,7 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
|||||||
fs(fmt("tooltip[waypoint_add;%s]", ES"Add waypoint"))
|
fs(fmt("tooltip[waypoint_add;%s]", ES"Add waypoint"))
|
||||||
|
|
||||||
if #data.waypoints == 0 then return end
|
if #data.waypoints == 0 then return end
|
||||||
|
fs("style_type[label;font=bold;font_size=17]")
|
||||||
|
|
||||||
for i, v in ipairs(data.waypoints) do
|
for i, v in ipairs(data.waypoints) do
|
||||||
local y = yextra + 1.35 + (i - (i * 0.3))
|
local y = yextra + 1.35 + (i - (i * 0.3))
|
||||||
@ -276,8 +319,6 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
|||||||
waypoint_name = snip(waypoint_name, lim)
|
waypoint_name = snip(waypoint_name, lim)
|
||||||
end
|
end
|
||||||
|
|
||||||
fs"style_type[label;font_size=17]"
|
|
||||||
|
|
||||||
local hex = fmt("%02x", v.color)
|
local hex = fmt("%02x", v.color)
|
||||||
|
|
||||||
while #hex < 6 do
|
while #hex < 6 do
|
||||||
@ -332,11 +373,10 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len)
|
|||||||
|
|
||||||
local pos = str_to_pos(data.waypoints[i].pos)
|
local pos = str_to_pos(data.waypoints[i].pos)
|
||||||
get_isometric_view(fs, pos, 0.6, y - 2.5)
|
get_isometric_view(fs, pos, 0.6, y - 2.5)
|
||||||
fs("image", 2.7, y - 1.5, 0.3, 0.3, PNG.flag)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
fs"style_type[label;font_size=16]"
|
fs"style_type[label;font=normal;font_size=16]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_bag_fs(fs, data, name, esc_name, bag_size, yextra)
|
local function get_bag_fs(fs, data, name, esc_name, bag_size, yextra)
|
||||||
@ -640,11 +680,11 @@ local function get_inventory_fs(player, data, fs)
|
|||||||
max_val += (award_list_nb * 13)
|
max_val += (award_list_nb * 13)
|
||||||
|
|
||||||
elseif data.subcat == 5 then
|
elseif data.subcat == 5 then
|
||||||
local wp_nb = #data.waypoints
|
local wp = #data.waypoints
|
||||||
|
|
||||||
if wp_nb > 0 then
|
if wp > 0 then
|
||||||
local mul = (wp_nb > 8 and 7) or (wp_nb > 4 and 6) or 5
|
local mul = (wp > 8 and 7) or (wp > 4 and 6) or 5
|
||||||
max_val += 11 + (wp_nb * mul)
|
max_val += 11 + (wp * mul)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -758,27 +798,38 @@ end
|
|||||||
|
|
||||||
local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_size, _btn_size)
|
local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_size, _btn_size)
|
||||||
local custom_recipe = i3.craft_types[rcp.type]
|
local custom_recipe = i3.craft_types[rcp.type]
|
||||||
|
local cooking = rcp.type == "cooking"
|
||||||
|
local fuel = rcp.type == "fuel"
|
||||||
|
|
||||||
if custom_recipe or shapeless or rcp.type == "cooking" then
|
if custom_recipe or shapeless or cooking then
|
||||||
local icon = custom_recipe and custom_recipe.icon or shapeless and "shapeless" or "furnace"
|
local icon, tooltip = PNG.blank
|
||||||
|
|
||||||
if not custom_recipe then
|
if custom_recipe and true_str(custom_recipe.icon) then
|
||||||
icon = fmt("i3_%s.png^\\[resize:16x16", icon)
|
icon = fmt("%s^\\[resize:16x16", custom_recipe.icon)
|
||||||
|
elseif shapeless then
|
||||||
|
icon = PNG.shapeless
|
||||||
end
|
end
|
||||||
|
|
||||||
local pos_x = right + btn_size + 0.42
|
local pos_x = right + btn_size + 0.42
|
||||||
local pos_y = data.yoffset + 0.9
|
local pos_y = data.yoffset + 0.9
|
||||||
|
|
||||||
if sub(icon, 1, 10) == "i3_furnace" then
|
if cooking then
|
||||||
fs("animated_image", pos_x, pos_y, 0.5, 0.5, PNG.furnace_anim, 8, 180)
|
fs("animated_image", pos_x, pos_y, 0.5, 0.5, PNG.furnace_anim, 8, 180)
|
||||||
else
|
else
|
||||||
fs("image", pos_x, pos_y, 0.5, 0.5, icon)
|
fs("image", pos_x, pos_y, 0.5, 0.5, icon)
|
||||||
end
|
end
|
||||||
|
|
||||||
local tooltip = custom_recipe and custom_recipe.description or
|
if custom_recipe and true_str(custom_recipe.description) then
|
||||||
shapeless and S"Shapeless" or S"Cooking"
|
tooltip = custom_recipe.description
|
||||||
|
elseif shapeless then
|
||||||
|
tooltip = S"Shapeless"
|
||||||
|
elseif cooking then
|
||||||
|
tooltip = S"Cooking"
|
||||||
|
end
|
||||||
|
|
||||||
fs("tooltip", pos_x, pos_y, 0.5, 0.5, ESC(tooltip))
|
if tooltip then
|
||||||
|
fs("tooltip", pos_x, pos_y, 0.5, 0.5, ESC(tooltip))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local arrow_X = right + 0.2 + (_btn_size or i3.ITEM_BTN_SIZE)
|
local arrow_X = right + 0.2 + (_btn_size or i3.ITEM_BTN_SIZE)
|
||||||
@ -787,7 +838,7 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
|
|||||||
|
|
||||||
fs("image", arrow_X, Y + 0.06, 1, 1, PNG.arrow)
|
fs("image", arrow_X, Y + 0.06, 1, 1, PNG.arrow)
|
||||||
|
|
||||||
if rcp.type == "fuel" then
|
if fuel then
|
||||||
fs("animated_image", X + 0.05, Y, i3.ITEM_BTN_SIZE, i3.ITEM_BTN_SIZE, PNG.fire_anim, 8, 180)
|
fs("animated_image", X + 0.05, Y, i3.ITEM_BTN_SIZE, i3.ITEM_BTN_SIZE, PNG.fire_anim, 8, 180)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -1145,7 +1196,7 @@ local function get_export_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_
|
|||||||
fmt("craft_%s", name), ES("Craft (×@1)", stack_fs))
|
fmt("craft_%s", name), ES("Craft (×@1)", stack_fs))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_rcp_extra(player, fs, data, panel, is_recipe, is_usage)
|
local function get_rcp_extra(fs, player, data, panel, is_recipe, is_usage)
|
||||||
fs"container[0,0.075]"
|
fs"container[0,0.075]"
|
||||||
local rn = panel.rcp and #panel.rcp
|
local rn = panel.rcp and #panel.rcp
|
||||||
|
|
||||||
@ -1184,7 +1235,7 @@ local function get_rcp_extra(player, fs, data, panel, is_recipe, is_usage)
|
|||||||
fs"container_end[]"
|
fs"container_end[]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_items_fs(fs, data, full_height)
|
local function hide_items(player, data)
|
||||||
if compression_active(data) then
|
if compression_active(data) then
|
||||||
local new = {}
|
local new = {}
|
||||||
|
|
||||||
@ -1198,6 +1249,25 @@ local function get_items_fs(fs, data, full_height)
|
|||||||
data.items = new
|
data.items = new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not core.is_creative_enabled(data.player_name) then
|
||||||
|
local new = {}
|
||||||
|
|
||||||
|
for i = 1, #data.items do
|
||||||
|
local item = data.items[i]
|
||||||
|
local recipes, usages = get_recipes(player, item)
|
||||||
|
|
||||||
|
if recipes or usages then
|
||||||
|
insert(new, item)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
data.items = new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_items_fs(fs, player, data, full_height)
|
||||||
|
hide_items(player, data)
|
||||||
|
|
||||||
local items = data.alt_items or data.items or {}
|
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
|
||||||
@ -1287,7 +1357,7 @@ local function get_favs(fs, data)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_panels(player, data, fs, full_height)
|
local function get_panels(fs, player, data, full_height)
|
||||||
local _title = {name = "title", height = 1.4}
|
local _title = {name = "title", height = 1.4}
|
||||||
local _favs = {name = "favs", height = 2.23}
|
local _favs = {name = "favs", height = 2.23}
|
||||||
local _items = {name = "items", height = full_height}
|
local _items = {name = "items", height = full_height}
|
||||||
@ -1316,9 +1386,9 @@ local function get_panels(player, data, fs, full_height)
|
|||||||
local is_recipe, is_usage = panel.name == "recipes", panel.name == "usages"
|
local is_recipe, is_usage = panel.name == "recipes", panel.name == "usages"
|
||||||
|
|
||||||
if is_recipe or is_usage then
|
if is_recipe or is_usage then
|
||||||
get_rcp_extra(player, fs, data, panel, is_recipe, is_usage)
|
get_rcp_extra(fs, player, data, panel, is_recipe, is_usage)
|
||||||
elseif panel.name == "items" then
|
elseif panel.name == "items" then
|
||||||
get_items_fs(fs, data, full_height)
|
get_items_fs(fs, player, data, full_height)
|
||||||
elseif panel.name == "title" then
|
elseif panel.name == "title" then
|
||||||
get_header(fs, data)
|
get_header(fs, data)
|
||||||
elseif panel.name == "favs" then
|
elseif panel.name == "favs" then
|
||||||
@ -1327,7 +1397,7 @@ local function get_panels(player, data, fs, full_height)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_tabs_fs(player, data, fs, full_height)
|
local function get_tabs_fs(fs, player, data, full_height)
|
||||||
local tab_len, tab_hgh, c, over = 3, 0.5, 0
|
local tab_len, tab_hgh, c, over = 3, 0.5, 0
|
||||||
local _tabs = copy(i3.tabs)
|
local _tabs = copy(i3.tabs)
|
||||||
|
|
||||||
@ -1428,10 +1498,10 @@ local function make_fs(player, data)
|
|||||||
tab.formspec(player, data, fs)
|
tab.formspec(player, data, fs)
|
||||||
end
|
end
|
||||||
|
|
||||||
get_panels(player, data, fs, full_height)
|
get_panels(fs, player, data, full_height)
|
||||||
|
|
||||||
if #i3.tabs > 1 then
|
if #i3.tabs > 1 then
|
||||||
get_tabs_fs(player, data, fs, full_height)
|
get_tabs_fs(fs, player, data, full_height)
|
||||||
end
|
end
|
||||||
|
|
||||||
--get_debug_grid(data, fs, full_height)
|
--get_debug_grid(data, fs, full_height)
|
||||||
|
10
src/hud.lua
10
src/hud.lua
@ -34,10 +34,12 @@ local function init_hud(player)
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
core.after(0, function()
|
if not i3.legacy_inventory then
|
||||||
player:hud_set_hotbar_itemcount(i3.HOTBAR_LEN)
|
core.after(0, function()
|
||||||
player:hud_set_hotbar_image"i3_hotbar.png"
|
player:hud_set_hotbar_itemcount(i3.HOTBAR_LEN)
|
||||||
end)
|
player:hud_set_hotbar_image"i3_hotbar.png"
|
||||||
|
end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function show_hud(player, data)
|
local function show_hud(player, data)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
local PNG = {
|
local PNG = {
|
||||||
|
blank = "i3_blank.png",
|
||||||
bg = "i3_bg.png",
|
bg = "i3_bg.png",
|
||||||
bg_full = "i3_bg_full.png",
|
bg_full = "i3_bg_full.png",
|
||||||
bg_content = "i3_bg_content.png",
|
bg_content = "i3_bg_content.png",
|
||||||
@ -27,6 +28,7 @@ local PNG = {
|
|||||||
tab_small = "i3_tab_small.png",
|
tab_small = "i3_tab_small.png",
|
||||||
tab_top = "i3_tab.png^\\[transformFY",
|
tab_top = "i3_tab.png^\\[transformFY",
|
||||||
furnace_anim = "i3_furnace_anim.png",
|
furnace_anim = "i3_furnace_anim.png",
|
||||||
|
shapeless = "i3_shapeless.png",
|
||||||
bag = "i3_bag.png",
|
bag = "i3_bag.png",
|
||||||
armor = "i3_armor.png",
|
armor = "i3_armor.png",
|
||||||
awards = "i3_award.png",
|
awards = "i3_award.png",
|
||||||
|
Reference in New Issue
Block a user