Page 1 of 1
[0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 6:11 am
by DRY411S
At
https://wiki.factorio.com/Types/IconSpecification there are 2 options.
There is at least one mod out there that implements something like this:
Code: Select all
icon = "__base__/graphics/icons/foo.png",
icons = {
{
icon = "__base__/graphics/icons/foo2.png",
icon_size = 32
},
{
icon = "__base__/graphics/icons/foo3.png",
icon_size = 32
tint = { a = 0.75, b = 0, g = 0, r = 0 }
},
{
icon = "__base__/graphics/icons/foo4.png",
icon_size = 32
tint = { a = 0.75, b = 0.5, g = 0.5, r = 0.5 }
}
}
The specification mandates that if icon is specified, then icon_size is mandatory and must also be present. It is however possible to implement the above where the specification has not been followed, and icon_size is missing when icon is present.
Mods should use 1 IconSpecification option or another, not all of one and part of another. It appears that the game base code recognises the IconSpecification Option 1, and 'forgives' the bad implementation of Option 2.
I would like the base game to reject mod code like the above that does not conform to specification
[EDIT]. Sorry my example code is wrong. It was missing the icon_size completely!
Re: [0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 6:19 am
by Optera
Correct me if I misread your post.
You defined prototype.icon and prototype.icons, but not prototype.icon_size
With icons set, icon and icon_size are ignored entirely.
Re: [0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 6:28 am
by DRY411S
Optera wrote: ↑Sun Mar 15, 2020 6:19 am
Correct me if I misread your post.
You defined prototype.icon and prototype.icons, but not prototype.icon_size
It wasn't me, it was somebody else.
Optera wrote: ↑Sun Mar 15, 2020 6:19 amWith icons set, icon and icon_size are ignored entirely.
That isn't what the specification says. It says there are 2 options. It doesn't say that if Option 1 is used then an incorrect implementation of Option 2 is ignored.
My issue with this is that I have to put code in my mod that identifies when other mods have incorrectly implemented off specification. I would rather the base game code errored on the off-specification mods instead of mine crashing.
[Edit] I've also contacted mod authors and asked them to use the correct specification. If they have stuff in their mods that the game is ignoroing, they should remove it.
Re: [0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 6:41 am
by Optera
I too have mods that have to handle this weirdness, but haven't had any problems with ignoring icon in presence of icons
Code: Select all
if icons then
--use icons
elseif icon and icon_size
-- use icon and icon_size
else
-- error
end
The specification could be clearer, but I'm fairly certain that's how the base works too.
Re: [0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 9:05 am
by posila
Can't reproduce.
- icon_size_missing.png (8.62 KiB) Viewed 2241 times
Code: Select all
{
type = "item",
name = "fast-transport-belt",
--icon_size = 64, icon_mipmaps = 4,
icon = "__base__/graphics/icons/foo.png",
icons = {
{
icon = "__base__/graphics/icons/foo2.png"
},
{
icon = "__base__/graphics/icons/foo3.png",
tint = { a = 0.75, b = 0, g = 0, r = 0 }
},
{
icon = "__base__/graphics/icons/foo4.png",
tint = { a = 0.75, b = 0.5, g = 0.5, r = 0.5 }
}
},
subgroup = "belt",
order = "a[transport-belt]-b[fast-transport-belt]",
place_result = "fast-transport-belt",
stack_size = 100
},
Re: [0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 9:35 am
by DRY411S
posila wrote: ↑Sun Mar 15, 2020 9:05 am
Can't reproduce.
icon_size_missing.png
Code: Select all
{
type = "item",
name = "fast-transport-belt",
--icon_size = 64, icon_mipmaps = 4,
icon = "__base__/graphics/icons/foo.png",
icons = {
{
icon = "__base__/graphics/icons/foo2.png"
},
{
icon = "__base__/graphics/icons/foo3.png",
tint = { a = 0.75, b = 0, g = 0, r = 0 }
},
{
icon = "__base__/graphics/icons/foo4.png",
tint = { a = 0.75, b = 0.5, g = 0.5, r = 0.5 }
}
},
subgroup = "belt",
order = "a[transport-belt]-b[fast-transport-belt]",
place_result = "fast-transport-belt",
stack_size = 100
},
Put icon_size in the icons { } table
Re: [0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 9:38 am
by posila
Code: Select all
{
type = "item",
name = "fast-transport-belt",
--icon_size = 64, icon_mipmaps = 4,
icon = "__base__/graphics/icons/foo.png",
icons = {
icon_size = 64,
{
icon = "__base__/graphics/icons/foo2.png"
},
{
icon = "__base__/graphics/icons/foo3.png",
tint = { a = 0.75, b = 0, g = 0, r = 0 }
},
{
icon = "__base__/graphics/icons/foo4.png",
tint = { a = 0.75, b = 0.5, g = 0.5, r = 0.5 }
}
},
subgroup = "belt",
order = "a[transport-belt]-b[fast-transport-belt]",
place_result = "fast-transport-belt",
stack_size = 100
},
Same error
Re: [0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 9:55 am
by DRY411S
posila wrote: ↑Sun Mar 15, 2020 9:38 am
Code: Select all
{
type = "item",
name = "fast-transport-belt",
--icon_size = 64, icon_mipmaps = 4,
icon = "__base__/graphics/icons/foo.png",
icons = {
icon_size = 64,
{
icon = "__base__/graphics/icons/foo2.png"
},
{
icon = "__base__/graphics/icons/foo3.png",
tint = { a = 0.75, b = 0, g = 0, r = 0 }
},
{
icon = "__base__/graphics/icons/foo4.png",
tint = { a = 0.75, b = 0.5, g = 0.5, r = 0.5 }
}
},
subgroup = "belt",
order = "a[transport-belt]-b[fast-transport-belt]",
place_result = "fast-transport-belt",
stack_size = 100
},
Same error
I'm really sorry, I pasted the wrong sample code at the start of the topic. I have corrected it. The code should have included icon_size entries for every icon in the icons table.
OK. Please place the icon_size inside every icon entry in the icons table, so:
Code: Select all
{
type = "item",
name = "fast-transport-belt",
--icon_size = 64, icon_mipmaps = 4,
icon = "__base__/graphics/icons/foo.png",
icons = {
{
icon = "__base__/graphics/icons/foo2.png",
icon_size = 64
},
{
icon = "__base__/graphics/icons/foo3.png",
icon_size = 64,
tint = { a = 0.75, b = 0, g = 0, r = 0 }
},
{
icon = "__base__/graphics/icons/foo4.png",
icon_size = 64,
tint = { a = 0.75, b = 0.5, g = 0.5, r = 0.5 }
}
},
subgroup = "belt",
order = "a[transport-belt]-b[fast-transport-belt]",
place_result = "fast-transport-belt",
stack_size = 100
},
That is the construct I am seeing that is not throwing an error. It appears in this mod >>>
https://mods.factorio.com/mod/team_competition
Re: [0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 10:03 am
by posila
I see. That's a valid definition. I have added information about icons taking priority over icon into the wiki page.
Re: [0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 10:13 am
by DRY411S
posila wrote: ↑Sun Mar 15, 2020 10:03 am
I see. That's a valid definition. I have added information about icons taking priority over icon into the wiki page.
Ok thanks. I can amend my mod with confidence now.
Re: [0.18.10] Game accepts items that don't conform to the prototype definition
Posted: Sun Mar 15, 2020 10:23 am
by DRY411S
Optera wrote: ↑Sun Mar 15, 2020 6:41 am
I too have mods that have to handle this weirdness, but haven't had any problems with ignoring icon in presence of icons
Code: Select all
if icons then
--use icons
elseif icon and icon_size
-- use icon and icon_size
else
-- error
end
The specification could be clearer, but I'm fairly certain that's how the base works too.
You still need to use icon_size though if it is present, since it does not have to be contained in icons