[Rseding91] [1.0.0] active_index is 1 for a brand new empty blueprint book, is error to use this as inventory index
[Rseding91] [1.0.0] active_index is 1 for a brand new empty blueprint book, is error to use this as inventory index
A brand new blueprint book on the cursor has LuaItemStack.active_index == 1, but LuaItemStack.get_inventory(defines.inventory.item_main)[1] is an error because that inventory has a length of zero. I can, of course, check the length and compare it to the index, but it doesn't seem right that the active index is ever an invalid index that is not also an invalid value for indexing in general (like, say, nil).
Re: [1.0.0] active_index is 1 for a brand new empty blueprint book, is error to use this as inventory index
I'm not really sure what the "fix" would be; I could make it return nil if the inventory size is zero?
If you want to get ahold of me I'm almost always on Discord.
Re: [1.0.0] active_index is 1 for a brand new empty blueprint book, is error to use this as inventory index
At least a couple of existing mods assume that active_index will be nil when it's not to be used as an index. I found this while fixing one of them. I would expect it to be nil, as well.
Re: [1.0.0] active_index is 1 for a brand new empty blueprint book, is error to use this as inventory index
I second the nil if zero route!
- smartguy1196
- Inserter
- Posts: 23
- Joined: Tue Nov 10, 2020 6:09 am
- Contact:
Re: [Rseding91] [1.0.0] active_index is 1 for a brand new empty blueprint book, is error to use this as inventory index
I thirded the nil if zero route!