Page 1 of 1

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

Posted: Fri Apr 22, 2022 7:26 pm
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

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

Posted: Fri Apr 22, 2022 10:08 pm
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.

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

Posted: Sat Apr 23, 2022 2:44 am
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).

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

Posted: Sat Apr 23, 2022 5:11 am
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.

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

Posted: Sat Apr 23, 2022 8:27 pm
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