Can't GetItemCount on the PC via Formlist of keywords

Post » Tue Feb 05, 2013 12:14 am

I'm trying to determine the number of potions on the PC, when the PC is using an activator where the script is attached to (it's part of a simple "HUB" script for sharing a potion container across several interior locations). A menu gives the options to Store all, take all, inventory, exit. The Store All section doesn't work, that's where in the script the Player ref is used instead of a container.

Problem : When moving from the container HUB to the PC, GetItemCount on the container returns the correct value. However it doesn't work on the PC.

The script is simple (well... not so it seems in the end), where I'm using one Formlist containing the "valid" keywords hence defining one single category : all items having at least one of its keywords will get processed and moved into a container HUB located in an inaccessible cell. Actually, the Formlist I'm testing with currently has one single Keyword : VendorItemPotion.

Here is the script (I haven't include the whole script, only the relevant parts for a workable script) :
Scriptname fj_BHStorageSingleCategoryScript extends ObjectReferenceObjectReference Property rContainerCategoryHUB Auto{Associated shared HUB container in an unaccessible cell}Formlist Property fCategory Auto{Formlist of Keywords : any item having one of its Keywords will get processed}Int iIndexKeywords ;Index for traversing the FormlistInt iCountPerK ;Number of items matching a specific Keyword in the FormlistInt iCountItem ;Number of items matching the whole Category (all the Keywords in the Formlist)Event OnInit()	iCountKeywords = fCategory.GetSize()EndEventEvent OnActivate(ObjectReference akActionRef)	If akActionRef == Game.GetPlayer()		iCountItem = 0		iIndexKeywords = iCountKeywords ; number of Keywords in the Formlist		ShowMenu(0, akActionRef)	EndifEndEventFunction ShowMenu(Int iButton = 0, ObjectReference akActionRef)iButton = mMainMenuFourChoices.Show()If iButton == 0 ;*** STORE ALL items	While iIndexKeywords		iIndexKeywords -= 1		[color=#ffa07a]iCountPerK = akActionRef.GetItemCount(fCategory.GetAt(iIndexKeywords) As Keyword)[/color]		iCountItem += iCountPerK		akActionRef. .RemoveItem(kCurrentKeyword, iCountPerK, True, rContainerCategoryHUB)debug.Notification("STORE ALL  iCountKeywords = "+iCountKeywords+"; iIndexKeywords = "+iIndexKeywords+"; iCountPerK = "+iCountPerK+"; iCountItem = "+iCountItem)	EndWhileElseIf iButton == 1 ;*** TAKE ALL Items - cut down to minimalistic functionality	rContainerCategoryHUB.RemoveAllItems(akActionRef, True, True)ElseIf iButton == 2 ;*** INVENTORY	rContainerCategoryHUB.Activate(akActionRef)	Utility.Wait(0.1)	While iIndexKeywords		iIndexKeywords -= 1		iCountPerK = rContainerCategoryHUB.GetItemCount(fCategory.GetAt(iIndexKeywords) As Keyword)		iCountItem += iCountPerKdebug.Notification("INVENTORY  iCountKeywords = "+iCountKeywords+"; iIndexKeywords = "+iIndexKeywords+"; iCountPerK = "+iCountPerK+"; iCountItem = "+iCountItem)	EndWhileElseIf iButton &--#62;= 3EndIfEndFunction
With one Keyword in the Formlist, the TAKE ALL section notification shows incxorrect values for iCountPerK : it always return a negative value, even when there's no item matching the Keyword criteria. However the section INVENTORY works prefectly, iCountPerK returning the correct value.

What am I doing wrong? Any tweek? Help!
User avatar
Leilene Nessel
 
Posts: 3428
Joined: Sun Apr 15, 2007 2:11 am

Return to V - Skyrim