GUI: show wear for recipe output

This commit is contained in:
Jean-Patrick Guerrero 2021-11-21 18:44:49 +01:00
parent b4d7dfddef
commit ec4e929491
3 changed files with 66 additions and 51 deletions

View File

@ -72,7 +72,7 @@ i3.files.groups()
i3.files.callbacks() i3.files.callbacks()
local storage = core.get_mod_storage() local storage = core.get_mod_storage()
local slz, dslz, str_to_pos, add_hud_waypoint = i3.get("slz", "dslz", "str_to_pos", "add_hud_waypoint") local slz, dslz, copy, str_to_pos, add_hud_waypoint = i3.get("slz", "dslz", "copy", "str_to_pos", "add_hud_waypoint")
local set_fs = i3.set_fs local set_fs = i3.set_fs
i3.data = dslz(storage:get_string "data") or {} i3.data = dslz(storage:get_string "data") or {}
@ -189,7 +189,7 @@ local function init_hudbar(player)
end end
local function save_data(player_name) local function save_data(player_name)
local _data = table.copy(i3.data) local _data = copy(i3.data)
for name, v in pairs(_data) do for name, v in pairs(_data) do
for dat in pairs(v) do for dat in pairs(v) do

View File

@ -721,11 +721,14 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
if rcp.type == "fuel" then if rcp.type == "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)
else return
end
local item = ItemStack(rcp.output) local item = ItemStack(rcp.output)
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 wear = item:get_wear()
local bt_s = i3.ITEM_BTN_SIZE * 1.2 local bt_s = i3.ITEM_BTN_SIZE * 1.2
local _name = fmt("_%s", name) local _name = fmt("_%s", name)
local pos local pos
@ -749,7 +752,7 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
fs("image", X, Y - 0.11, bt_s, bt_s, PNG.slot) fs("image", X, Y - 0.11, bt_s, bt_s, PNG.slot)
fs("item_image_button", fs("item_image_button",
X + 0.11, Y, i3.ITEM_BTN_SIZE, i3.ITEM_BTN_SIZE, X + 0.11, Y, i3.ITEM_BTN_SIZE, i3.ITEM_BTN_SIZE,
fmt("%s %u", name, count * (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1)), fmt("%s %u %u", name, count * (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1), wear),
_name, "") _name, "")
end end
@ -777,7 +780,6 @@ local function get_output_fs(fs, data, rcp, is_recipe, shapeless, right, btn_siz
fs(get_tooltip(_name, infos, pos)) fs(get_tooltip(_name, infos, pos))
end end
end end
end
local function get_grid_fs(fs, data, rcp, is_recipe) local function get_grid_fs(fs, data, rcp, is_recipe)
local width = rcp.width or 1 local width = rcp.width or 1

View File

@ -6,6 +6,10 @@ local mt2 = ItemStack("dye:red")
mt2:get_meta():set_string("description", "test red") mt2:get_meta():set_string("description", "test red")
mt2:get_meta():set_string("color", "#ff0") mt2:get_meta():set_string("color", "#ff0")
local mt3 = ItemStack("default:pick_diamond")
mt3:get_meta():set_string("description", "Worn Pick")
mt3:set_wear(10000)
minetest.register_craft({ minetest.register_craft({
output = mt:to_string(), output = mt:to_string(),
type = "shapeless", type = "shapeless",
@ -15,6 +19,15 @@ minetest.register_craft({
}, },
}) })
minetest.register_craft({
output = mt3:to_string(),
type = "shapeless",
recipe = {
"default:pick_mese",
"default:diamond",
},
})
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"
} }