Jump to content

OBSE ModCurrentCharge not working


VladiMatt

Recommended Posts

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

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

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

Oh wow, yup that fixed it! Thanks a ton for the tip!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...