VladiMatt Posted October 5, 2021 Share Posted October 5, 2021 while(CurItemNum < PlayerItemsNum) set CurItemNum to CurItemNum+1 ;;Print( "Checking Item " + (ToString CurItemNum) + " of " + (ToString PlayerItemsNum)) set CurItemObjID to Player.GetInventoryObject CurItemNum set CurItemEnchant to GetEnchantment CurItemObjID set CurItemCount to player.GetItemCount CurItemObjID if(CurItemEnchant) if(GetObjectCharge CurItemObjID != 0) ;;Print(ToString GetObjectCharge CurItemObjID) CurItemObjID.ModCurrentCharge timeDifference endif endif loop I'm trying to write a script that slowly recharges enchanted weapons every hour, and I've gotten as far as looping through and identifying some of the enchanted weapons in the player's inventory (for whatever reason this script can't detect full charge items, not that it needs to) The problem I'm running into is I can't get ModCurrentCharge to work at all, and when I call it the script halts without error and won't continue the loop. Anyone know what I'm doing wrong? Link to comment Share on other sites More sharing options...
KatsAwful Posted October 7, 2021 Share Posted October 7, 2021 Getting inventory items with this method is hacky, slow, and behaves in horribly unreliable ways. It also does not provide proper references, it provides objects that behave sorta like references. You want to use a ForEach loop, which returns an inventory reference. See here: https://htmlpreview.github.io/?https://github.com/llde/xOBSE/blob/master/obse_command_doc.html#Inventory_Reference Link to comment Share on other sites More sharing options...
VladiMatt Posted October 7, 2021 Author Share Posted October 7, 2021 Getting inventory items with this method is hacky, slow, and behaves in horribly unreliable ways. It also does not provide proper references, it provides objects that behave sorta like references. You want to use a ForEach loop, which returns an inventory reference. See here: https://htmlpreview.github.io/?https://github.com/llde/xOBSE/blob/master/obse_command_doc.html#Inventory_ReferenceOh wow, yup that fixed it! Thanks a ton for the tip! Link to comment Share on other sites More sharing options...
Recommended Posts