Page 1 of 1
[2.0.50] Error in data phase if item has icon with shift in struct form
Posted: Fri May 16, 2025 5:43 pm
by crusybl
The documentation for the
Icon.shift field says that the value should be a
Vector. The documentation for Vector says it can be either a struct of {x,y}, or an array with 2 entries, where the first is x, and the latter is y.
However if you define an item with an
icons array, and one of the elements has an shift in the {x = 1, y = 2} form, the quality mod crashes during data-updates:
Code: Select all
Failed to load mods: __core__/lualib/util.lua:207: attempt to perform arithmetic on field '?' (a nil value)
stack traceback:
__core__/lualib/util.lua:207: in function 'mul_shift'
__quality__/prototypes/recycling.lua:64: in function 'generate_recycling_recipe_icons_from_item'
__quality__/prototypes/recycling.lua:147: in function 'add_recipe_values'
__quality__/prototypes/recycling.lua:208: in function 'generate_recycling_recipe'
__quality__/data-updates.lua:5: in main chunk
Mods to be disabled:
• quality (2.0.47)
This appears to be because the mul_shift function:
Code: Select all
function util.mul_shift(shift, scale)
if not (shift and scale) then
return shift
end
return {shift[1] * scale, shift[2] * scale}
end
Is always assuming that the shift is in the array form.
Re: [2.0.50] Error in data phase if item has icon with shift in struct form
Posted: Wed May 21, 2025 7:46 pm
by Rseding91
Can you provide a sample mod/piece of lua code that reproduces this error? I'm having trouble getting anything to error regardless of how I define the shift value.
Re: [2.0.50] Error in data phase if item has icon with shift in struct form
Posted: Mon Aug 25, 2025 5:00 am
by Quorken
I encountered the same bug.
Simple piece of code (data.lua):
Code: Select all
data.raw["item"]["gun-turret"].icons = {
{
icon=data.raw["item"]["gun-turret"].icon
},
{
icon=data.raw["item"]["gun-turret"].icon,
scale = 0.5,
shift = {x=-8, y=-8}
}
}
data.raw["item"]["gun-turret"].icon = nil
Yields the error:
Code: Select all
3.099 Loading mod quality 2.0.60 (data-updates.lua)
3.112 Error ModManager.cpp:1758: Failed to load mod "quality": __core__/lualib/util.lua:207: attempt to perform arithmetic on field '?' (a nil value)
stack traceback:
__core__/lualib/util.lua:207: in function 'mul_shift'
__quality__/prototypes/recycling.lua:64: in function 'generate_recycling_recipe_icons_from_item'
__quality__/prototypes/recycling.lua:147: in function 'add_recipe_values'
__quality__/prototypes/recycling.lua:208: in function 'generate_recycling_recipe'
__quality__/data-updates.lua:5: in main chunk
3.153 Loading mod core 0.0.0 (data.lua)
3.230 Checksum for core: 2750550925
3.339 Error ModManager.cpp:1758: Error in assignID: recipe-category with name 'recycling' does not exist.
Source: default (utility-constants).
3.349 Info PlayerData.cpp:66: Local player-data.json unavailable
3.349 Info PlayerData.cpp:69: Cloud player-data.json available, timestamp 1756097738
3.354 Post-data load graphics options: [Light occlusion: no]
3.533 Initial atlas bitmap size is 8192
3.555 Created an atlas bitmap (size 4096x496) [icon, not-compressed, mipmap, linear-minification, linear-magnification, linear-mip-level]
4.845 Loading 3D bitmaps.
4.856 Texture processor created (4096). GPU accelerated compression Supported: yes, Enabled: yes/yes. Test passed. YCoCgDXT PSNR: 35.83, BC3 PSNR: 33.82
4.862 Parallel sprite loader initialized (threads: 5, bitmaps: 145)
5.234 Sprites loaded
5.269 Generated mipmaps (5) for atlas [0] of size 4096x496
5.269 Custom mipmaps uploaded (116)
5.285 Video memory usage: 10.32 MB (Atlases: 10.32 MB, Textures: 0.00 MB)
5.313 Factorio initialised
5.319 Failed to load mods: __core__/lualib/util.lua:207: attempt to perform arithmetic on field '?' (a nil value)
stack traceback:
__core__/lualib/util.lua:207: in function 'mul_shift'
__quality__/prototypes/recycling.lua:64: in function 'generate_recycling_recipe_icons_from_item'
__quality__/prototypes/recycling.lua:147: in function 'add_recipe_values'
__quality__/prototypes/recycling.lua:208: in function 'generate_recycling_recipe'
__quality__/data-updates.lua:5: in main chunk
Mods to be disabled:
• quality (2.0.60)
Re: [2.0.50] Error in data phase if item has icon with shift in struct form
Posted: Tue Sep 02, 2025 7:53 am
by boskid
Thanks for the report. Issue (util.mul_shift not accepting struct) is now fixed for 2.0.66.