GUI: show wear for recipe output
This commit is contained in:
parent
b4d7dfddef
commit
ec4e929491
4
init.lua
4
init.lua
|
@ -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
|
||||||
|
|
100
src/gui.lua
100
src/gui.lua
|
@ -721,61 +721,63 @@ 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
|
||||||
local item = ItemStack(rcp.output)
|
end
|
||||||
local meta = item:get_meta()
|
|
||||||
local name = item:get_name()
|
|
||||||
local count = item:get_count()
|
|
||||||
local bt_s = i3.ITEM_BTN_SIZE * 1.2
|
|
||||||
local _name = fmt("_%s", name)
|
|
||||||
local pos
|
|
||||||
|
|
||||||
if meta:get_string("color") ~= "" or meta:get_string("palette_index") ~= "" then
|
local item = ItemStack(rcp.output)
|
||||||
local rcp_usg = is_recipe and "rcp" or "usg"
|
local meta = item:get_meta()
|
||||||
|
local name = item:get_name()
|
||||||
|
local count = item:get_count()
|
||||||
|
local wear = item:get_wear()
|
||||||
|
local bt_s = i3.ITEM_BTN_SIZE * 1.2
|
||||||
|
local _name = fmt("_%s", name)
|
||||||
|
local pos
|
||||||
|
|
||||||
fs(fmt("style_type[list;size=%f]", i3.ITEM_BTN_SIZE))
|
if meta:get_string("color") ~= "" or meta:get_string("palette_index") ~= "" then
|
||||||
fs("listcolors[#bababa50;#bababa99]")
|
local rcp_usg = is_recipe and "rcp" or "usg"
|
||||||
fs(fmt("list[detached:i3_output_%s_%s;main;%f,%f;1,1;]", rcp_usg, data.player_name, X + 0.11, Y))
|
|
||||||
fs("button", X + 0.11, Y, i3.ITEM_BTN_SIZE, i3.ITEM_BTN_SIZE, _name, "")
|
|
||||||
|
|
||||||
local inv = core.get_inventory {
|
fs(fmt("style_type[list;size=%f]", i3.ITEM_BTN_SIZE))
|
||||||
type = "detached",
|
fs("listcolors[#bababa50;#bababa99]")
|
||||||
name = fmt("i3_output_%s_%s", rcp_usg, data.player_name)
|
fs(fmt("list[detached:i3_output_%s_%s;main;%f,%f;1,1;]", rcp_usg, data.player_name, X + 0.11, Y))
|
||||||
}
|
fs("button", X + 0.11, Y, i3.ITEM_BTN_SIZE, i3.ITEM_BTN_SIZE, _name, "")
|
||||||
|
|
||||||
inv:set_stack("main", 1, item)
|
local inv = core.get_inventory {
|
||||||
pos = {x = X + 0.11, y = Y}
|
type = "detached",
|
||||||
else
|
name = fmt("i3_output_%s_%s", rcp_usg, data.player_name)
|
||||||
fs("image", X, Y - 0.11, bt_s, bt_s, PNG.slot)
|
|
||||||
fs("item_image_button",
|
|
||||||
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)),
|
|
||||||
_name, "")
|
|
||||||
end
|
|
||||||
|
|
||||||
local def = reg_items[name]
|
|
||||||
local unknown = not def or nil
|
|
||||||
local desc = def and def.description
|
|
||||||
local weird = name ~= "" and desc and weird_desc(desc) or nil
|
|
||||||
local burntime = i3.fuel_cache[name] and i3.fuel_cache[name].burntime
|
|
||||||
|
|
||||||
local short_desc = meta:get_string("short_description")
|
|
||||||
local long_desc = meta:get_string("description")
|
|
||||||
local meta_desc = (short_desc ~= "" and short_desc) or (long_desc ~= "" and long_desc)
|
|
||||||
|
|
||||||
local infos = {
|
|
||||||
unknown = unknown,
|
|
||||||
weird = weird,
|
|
||||||
burntime = burntime,
|
|
||||||
repair = repairable(name),
|
|
||||||
rarity = rcp.rarity,
|
|
||||||
tools = rcp.tools,
|
|
||||||
meta_desc = meta_desc,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if next(infos) then
|
inv:set_stack("main", 1, item)
|
||||||
fs(get_tooltip(_name, infos, pos))
|
pos = {x = X + 0.11, y = Y}
|
||||||
end
|
else
|
||||||
|
fs("image", X, Y - 0.11, bt_s, bt_s, PNG.slot)
|
||||||
|
fs("item_image_button",
|
||||||
|
X + 0.11, Y, i3.ITEM_BTN_SIZE, i3.ITEM_BTN_SIZE,
|
||||||
|
fmt("%s %u %u", name, count * (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1), wear),
|
||||||
|
_name, "")
|
||||||
|
end
|
||||||
|
|
||||||
|
local def = reg_items[name]
|
||||||
|
local unknown = not def or nil
|
||||||
|
local desc = def and def.description
|
||||||
|
local weird = name ~= "" and desc and weird_desc(desc) or nil
|
||||||
|
local burntime = i3.fuel_cache[name] and i3.fuel_cache[name].burntime
|
||||||
|
|
||||||
|
local short_desc = meta:get_string("short_description")
|
||||||
|
local long_desc = meta:get_string("description")
|
||||||
|
local meta_desc = (short_desc ~= "" and short_desc) or (long_desc ~= "" and long_desc)
|
||||||
|
|
||||||
|
local infos = {
|
||||||
|
unknown = unknown,
|
||||||
|
weird = weird,
|
||||||
|
burntime = burntime,
|
||||||
|
repair = repairable(name),
|
||||||
|
rarity = rcp.rarity,
|
||||||
|
tools = rcp.tools,
|
||||||
|
meta_desc = meta_desc,
|
||||||
|
}
|
||||||
|
|
||||||
|
if next(infos) then
|
||||||
|
fs(get_tooltip(_name, infos, pos))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
}
|
}
|
||||||
|
|
Ŝarĝante…
Reference in New Issue