I've been wrestling with an idea. The core problem I'm trying to solve is the fact that if you have an item with charges, if as the charges drop down to the point where you can't use the item and then you boost the charges back up the item remains unusable. If the item is 1 charge per use and has 3 charges, setting it to 4 charges makes it adjust to 4 uses. But if it's 1 charge per use and has 0 charges, setting it to 1 charge keeps it as 0 uses.
The two main solutions I've seen suggested to fix this problem are the following:
1, remove and re-add the use property. However, this would presumably clear the quickbar slot where the item was stored, which isn't acceptable.
EDIT: IT TURNS OUT THE ABOVE ACTUALLY WORKS.
2, have the player rest. The catch is that this needs to work in-combat, which means ForceRest needs to be used AND the player has to be restored to the previous feats/spells/HP at a minimum.
As a result, I've written some code that loops through feats starting at value 0 and going up to 1115 (the last feat by default, player tool 10). It checks the number of uses a feat has, stores this information as a local int, force rests, then decrements feat uses as appropriate.
The problem is that this produces a TMI loop. However, the code is perfectly fine looping from 0 to 100. And from 0 to 1000. And from 1000 to 1150. And from 900 to 1150. But 0 to 1115 apparently breaks the instruction limit and gives me a TMI message.
This obviously has bad implications since I also need to do the same sorts of things for spells.
Presumably I could do something like separate this out into multiple scripts -- have one script check 0-600, another check for 600-1115 and rest, another decrement 0-600 if needed, and a fourth to decrement 600-1115 if needed. But that obviously seems rather clunky and also has greater processor cost. And I'd need the same sort of thing for spells.
Any suggestions regarding this? Insight to offer on the TMI limit?