Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbith committed Jun 19, 2022
1 parent 563dc71 commit 5f413a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
26 changes: 14 additions & 12 deletions src/caches.lua
Expand Up @@ -31,26 +31,24 @@ local function cache_groups(group, groups)
local items = i3.groups[group].items
if #items <= 1 then return end

local c = 0
local px = 256
local limit = 10
local c, px, lim = 0, 256, 10
local sprite = "[combine:WxH"

for _, item in ipairs(items) do
local def = reg_items[item]
local texture = def.inventory_image
local tiles = def.tiles or def.tile_images
local texture = true_str(def.inventory_image) and def.inventory_image --or tiles[1]

if true_str(texture) then
texture = texture:gsub("%^", "\\^"):gsub(":", "\\:") .. "\\^[resize\\:150x150"
elseif is_cube(def.drawtype) then
local tiles = def.tiles or def.tile_images
if is_cube(def.drawtype) then
texture = get_cube(tiles)
elseif texture then
texture = texture:gsub("%^", "\\^"):gsub(":", "\\:") .. "\\^[resize\\:150x150"
end

if true_str(texture) then
if texture then
sprite = sprite .. fmt(":0,%u=%s", c * px, texture)
c++
if c == limit then break end
if c == lim then break end
end
end

Expand Down Expand Up @@ -331,12 +329,16 @@ local function init_cubes()
for name, def in pairs(reg_nodes) do
if def then
local id = core.get_content_id(name)
local tiles = def.tiles or def.tile_images
if is_cube(def.drawtype) then
local tiles = def.tiles or def.tile_images
i3.cubes[id] = get_cube(tiles)
elseif sub(def.drawtype, 1, 9) == "plantlike" or sub(def.drawtype, 1, 8) == "firelike" then
i3.plants[id] = def.inventory_image
local texture = true_str(def.inventory_image) and def.inventory_image or tiles[1]
if texture then
i3.plants[id] = texture
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/gui.lua
Expand Up @@ -1032,7 +1032,7 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
local btn_name = groups and fmt("group!%s!%s", groups[1], name) or name
local _count = count * (is_recipe and data.scrbar_rcp or data.scrbar_usg or 1)

if group_cache and group_cache.sprite then
if group_cache and group_cache.sprite and not large_recipe then
local sprite = ESC(group_cache.sprite)

fs("item_image_button", X, Y, btn_size, btn_size, "", btn_name, "")
Expand Down

0 comments on commit 5f413a1

Please sign in to comment.