Put a upper limit for sprite creation
This commit is contained in:
parent
56cb236025
commit
563dc719d0
|
@ -33,21 +33,24 @@ local function cache_groups(group, groups)
|
||||||
|
|
||||||
local c = 0
|
local c = 0
|
||||||
local px = 256
|
local px = 256
|
||||||
|
local limit = 10
|
||||||
local sprite = "[combine:WxH"
|
local sprite = "[combine:WxH"
|
||||||
|
|
||||||
for _, item in ipairs(items) do
|
for _, item in ipairs(items) do
|
||||||
local def = reg_items[item]
|
local def = reg_items[item]
|
||||||
local texture = def.inventory_image or def.wield_image
|
local texture = def.inventory_image
|
||||||
|
|
||||||
if true_str(texture) then
|
if true_str(texture) then
|
||||||
texture = texture:gsub("%^", "\\^"):gsub(":", "\\:") .. "\\^[resize\\:150x150"
|
texture = texture:gsub("%^", "\\^"):gsub(":", "\\:") .. "\\^[resize\\:150x150"
|
||||||
elseif is_cube(def.drawtype) then
|
elseif is_cube(def.drawtype) then
|
||||||
texture = get_cube(def.tiles)
|
local tiles = def.tiles or def.tile_images
|
||||||
|
texture = get_cube(tiles)
|
||||||
end
|
end
|
||||||
|
|
||||||
if true_str(texture) then
|
if true_str(texture) then
|
||||||
sprite = sprite .. fmt(":0,%u=%s", c * px, texture)
|
sprite = sprite .. fmt(":0,%u=%s", c * px, texture)
|
||||||
c++
|
c++
|
||||||
|
if c == limit then break end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -330,7 +333,8 @@ local function init_cubes()
|
||||||
local id = core.get_content_id(name)
|
local id = core.get_content_id(name)
|
||||||
|
|
||||||
if is_cube(def.drawtype) then
|
if is_cube(def.drawtype) then
|
||||||
i3.cubes[id] = get_cube(def.tiles)
|
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
|
elseif sub(def.drawtype, 1, 9) == "plantlike" or sub(def.drawtype, 1, 8) == "firelike" then
|
||||||
i3.plants[id] = def.inventory_image
|
i3.plants[id] = def.inventory_image
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,6 +11,7 @@ i3.group_stereotypes = {
|
||||||
stone = "default:stone",
|
stone = "default:stone",
|
||||||
leaves = "default:leaves",
|
leaves = "default:leaves",
|
||||||
coal = "default:coal_lump",
|
coal = "default:coal_lump",
|
||||||
|
fence = "default:fence_wood",
|
||||||
vessel = "vessels:glass_bottle",
|
vessel = "vessels:glass_bottle",
|
||||||
flower = "flowers:dandelion_yellow",
|
flower = "flowers:dandelion_yellow",
|
||||||
water_bucket = "bucket:bucket_water",
|
water_bucket = "bucket:bucket_water",
|
||||||
|
@ -26,6 +27,7 @@ i3.group_names = {
|
||||||
glass = S"Any glass",
|
glass = S"Any glass",
|
||||||
stick = S"Any stick",
|
stick = S"Any stick",
|
||||||
stone = S"Any stone",
|
stone = S"Any stone",
|
||||||
|
fence = S"Any fence",
|
||||||
carpet = S"Any carpet",
|
carpet = S"Any carpet",
|
||||||
flower = S"Any flower",
|
flower = S"Any flower",
|
||||||
leaves = S"Any leaves",
|
leaves = S"Any leaves",
|
||||||
|
|
|
@ -18,7 +18,7 @@ IMPORT("S", "ES", "translate", "ItemStack", "toupper")
|
||||||
IMPORT("get_sorting_idx", "compression_active", "compressible")
|
IMPORT("get_sorting_idx", "compression_active", "compressible")
|
||||||
IMPORT("get_bag_description", "get_detached_inv", "get_recipes")
|
IMPORT("get_bag_description", "get_detached_inv", "get_recipes")
|
||||||
IMPORT("maxn", "sort", "concat", "copy", "insert", "remove", "unpack")
|
IMPORT("maxn", "sort", "concat", "copy", "insert", "remove", "unpack")
|
||||||
IMPORT("get_group_stereotype", "extract_groups", "is_group", "item_has_groups", "get_group")
|
IMPORT("get_group_stereotype", "extract_groups", "groups_to_items", "is_group", "item_has_groups", "get_group")
|
||||||
|
|
||||||
local function fmt(elem, ...)
|
local function fmt(elem, ...)
|
||||||
if not fs_elements[elem] then
|
if not fs_elements[elem] then
|
||||||
|
@ -997,8 +997,8 @@ local function get_grid_fs(fs, data, rcp, is_recipe)
|
||||||
|
|
||||||
if is_group(name) then
|
if is_group(name) then
|
||||||
groups = group_cache and group_cache.groups or extract_groups(name)
|
groups = group_cache and group_cache.groups or extract_groups(name)
|
||||||
name = group_cache and group_cache.stereotype or
|
name = group_cache and (group_cache.stereotype or group_cache.items[1]) or
|
||||||
get_group_stereotype(groups[1]) or group_cache.items[1]
|
get_group_stereotype(groups[1]) or groups_to_items(groups)[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
local label = groups and "\nG" or ""
|
local label = groups and "\nG" or ""
|
||||||
|
|
Ŝarĝante…
Reference in New Issue