From 354561d54ca645c7f79df247a30bf14ec8d394d9 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sat, 18 Jun 2022 23:16:50 +0200 Subject: [PATCH] Finish animation for group buttons (yay) --- src/caches.lua | 16 +++++++++++++++- src/gui.lua | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/caches.lua b/src/caches.lua index eae61a3..8ec8f62 100644 --- a/src/caches.lua +++ b/src/caches.lua @@ -37,10 +37,12 @@ local function cache_groups(groupname, groups) for i = 1, nb_items do local item = items[i] local def = reg_items[item] - local texture = def.inventory_image or def.wield_image + local texture = def.inventory_image or def.wield_image or "" if is_cube(def.drawtype) then texture = get_cube(def.tiles) + elseif true_str(texture) then + texture = texture .. "\\^[resize\\:150x150" end sprite = sprite .. fmt(":0,%u=%s", (i - 1) * px, texture) @@ -50,6 +52,18 @@ local function cache_groups(groupname, groups) end end +core.register_chatcommand("test", { + func = function(name, param) + core.get_player_by_name(name):hud_add({ + hud_elem_type = "image", + position = {x = 0.6, y = 0.5}, + scale = {x = 1, y = 1}, + text = param + }) + return true + end +}) + local function get_item_usages(item, recipe, added) if is_group(item) then diff --git a/src/gui.lua b/src/gui.lua index 7bdb3ca..62964a8 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -1032,7 +1032,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe) local _count = count * (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1) if group_cache and group_cache.sprite then - local sprite = group_cache.sprite + local sprite = ESC(group_cache.sprite) fs("item_image_button", X, Y, btn_size, btn_size, "", btn_name, "") fs("animated_image", X + 0.01, Y + 0.01, 1.89, 1.89, sprite, #group_cache.items, 1000)