I’m looking into tips on optimizing the inventory command, if that’s possible. I’ve managed to keep most of my game fairly optimized, but I’ve noticed a slight lag when opening the inventory. I’m sure this is due to high item count as it gets worse when the inventory length grows. It’s not a terrible lag, but I worry that it could become more noticeable as time goes on.
For reference, my game has a lot of high count items. Example - when foraging, you can come away with 15 deadwood. So, your inventory might look something like this:
You're carrying:
(Creepy-crawlies) - eight locusts and 17 snails.
(Fish) - a catfish.
(Flowers) - three lavender flowers, six camas flowers, five marsh marigold flowers, and two elderberry flowers.
(Forage) - a turkey tail mushroom, 10 camas bulbs, nine cypress bark slabs, and three swamp cabbages.
(Tools) - a fishing basket.
This is obviously where the lag comes from, but I was wondering if there was a way to keep the high count system while optimizing it for lag? I’ve considered imposing an item limit, which would kind of suck considering that you need a fair few items for crafting, and it would make gameplay very tedious.
I’ve also played with the idea of creating dummy items to imply multiple items when there’s actually only a single physical item. I’ve done something similar with a coin purse. So, instead of having a physical purse item with lots of physical, tangible coins, you can have a singular physical purse item with intangible coins that can be discerned by observing the purse. See below:
class coin: Currency '(copper) coin*coins'
name = 'coin'
value = 0
;
coinPurse: Thing 'coin purse'
name = 'coin purse'
desc = "A leather purse, plain and simple. At the moment, <<if coin.value == 0>>the coin purse is void of coins. <<else if coin.value == 1>>the coin purse contains a single coin. <<else if coin.value >1>>the coin purse contains <<spellIntBelow(coin.value, 10)>> coins. <<end>> "
I’m sure I could somehow implement something similar in the inventory for each of my items, but of course, that would be a massive hassle and I’m not sure it would even eliminate lag if the lag is caused by “counting”.
I’m sorry if this is phrased strangely, but I hope I’m making sense. Has anyone dealt with something similar, or have you experienced inventory lag? How have you implemented optimizing for such things?