question on properties of LuaItemPrototype: flags = {"not-stackable"} and stack_size

Place to post guides, observations, things related to modding that are not mods themselves.
Daeruun
Inserter
Inserter
Posts: 43
Joined: Thu May 04, 2017 8:37 pm
Contact:

question on properties of LuaItemPrototype: flags = {"not-stackable"} and stack_size

Post by Daeruun »

Hello there,

my mod adds a custom item with

Code: Select all

data:extend(
{
    {
        type = "item",
        name = "LRM-dummy-item",
        icon = "__core__/graphics/cancel.png",
        icon_size = 64,
        stack_size = 1,
        flags = { "hidden", "not-stackable" },
        subgroup = "other",
    }
}
Now another mod tries to change stack_size - and the game won't load any more, complaining that the stack_size needs to be 1 if 'not-stackable' is set.

Is there a way to prevent changes to the stack_size value?
Should the other mod take care of the flag and this is their bug?
Or am I wrong in using the flag at all?


Best regards

Daeruun
Rseding91
Factorio Staff
Factorio Staff
Posts: 14248
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: question on properties of LuaItemPrototype: flags = {"not-stackable"} and stack_size

Post by Rseding91 »

It's the job of a given mod to leave the game in a working state when it's done doing its logic.

Your mod left it in a working state. If another mod comes along later and leaves it in a broken state then that mod needs to handle it.
If you want to get ahold of me I'm almost always on Discord.
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2768
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Re: question on properties of LuaItemPrototype: flags = {"not-stackable"} and stack_size

Post by FuryoftheStars »

Rseding91, any chance of just making it so that if the "not-stackable" flag is set that the stack_size property is just then ignored/overwritten as 1? It would make mod compatibility easier, I think. I mean, I don't know as if most modders even know to look out for this in such a situation (I didn't).
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2964
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: question on properties of LuaItemPrototype: flags = {"not-stackable"} and stack_size

Post by boskid »

No. If "not-stackable" flag would make stack_size be ignored, then it would be moving this issue onto us with modding help requests or bug reports like "i set stack_size to X>1 but it is ignored by game". There is a proper note on wiki for stack_size for Prototype/Item for at least 9 months mentioning "non-stackable" flag and for 4 years highlighting there are some limitations for the value.
Daeruun
Inserter
Inserter
Posts: 43
Joined: Thu May 04, 2017 8:37 pm
Contact:

Re: question on properties of LuaItemPrototype: flags = {"not-stackable"} and stack_size

Post by Daeruun »

Thanks a lot for the feedback.

If I understand correctly, this should be enough to prevent this error in data-final-fixes:

Code: Select all

    for _, item in pairs(data.raw.item) do
        if item.stackable then
            item.stack_size = item.stack_size * desired_multiplier
        end
    end
Post Reply

Return to “Modding discussion”