Summary: Reproducible inventory_tracker error related to item qualities when the only item of a type that doesn’t inherently allow variable quality is having its quality set.
Steps to reproduce:
- Create a standard Microworld.
- Create a stockpile and wait until all default spawned items are stored in it.
- Select the Silkweed Bundle (or the Oak Log) and set its quality with the following function (or similar):
e:add_component('stonehearth:item_quality'):initialize_quality(2, 'test', nil, {override_allow_variable_quality = true})
- If you had the game paused, unpause it now.
Expected Results: No error, item qualities properly applied.
Actual Results: Item qualities all seem to be working properly, as does the town overview inventory tracking, but some item tracker somewhere may be failing, because this error occurs:
release-947 (x64)[M][C]
invalid key to 'next'
stack traceback:
[C]: ?
[C]: in function '(for generator)'
...arth/services/server/inventory/inventory_tracker.lua:185: in function <...arth/services/server/inventory/inventory_tracker.lua:163>
[C]: ?
[C]: in function 'update'
radiant/modules/events.lua:59: in function '_update'
radiant/server.lua:67: in function <radiant/server.lua:64>
Notes: If you spawn a second Silkweed bundle first before setting the quality of one of them, the error doesn’t occur. You can then set the quality of both of them without the error occurring. If you then destroy both of those items and create a new third bundle and set its item quality, you get the error. So it appears to be related to having the only item of a type being tracked change item qualities (probably trying to destroy and create the appropriate item quality tables, which are members of the same container table that’s trying to get iterated through, at the same time).
Also, this doesn’t appear to happen with items that are designed to have variable item qualities, e.g., a Comfy Bed. Is there some sort of extra preparation/management that goes into handling such items that doesn’t happen with other items where item quality is forced with the override_allow_variable_quality flag?
For my purposes (with ACE), I can probably mixin to a bunch of entities to allow variable quality for anything that might cause a problem like this, but it still seems like something that should be fixed.
Version Number and Mods in use: Microworld