Difference between revisions of "GetItemCount - ObjectReference"
Jump to navigation
Jump to search
imported>HawkFest m (→Notes) |
imported>Terra Nova2 m (→Notes: typos) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 35: | Line 35: | ||
== Notes == | == Notes == | ||
* If the argument akItem is a keyword and the object reference is an actor this function will fail to operate properly. A solution is to transfer the contents of the actor's inventory to a container and call the function on that container ( [http://forums.bethsoft.com/topic/1441239-cant-getitemcount-on-the-pc-via-formlist-of-keywords/page__pid__22196680#entry22196680/ Source (EN)] - [http://forum.wiwiland.net/index.php?/topic/54019-getitemcount-fonctionne-sur-les-conteneurs-mais-pas-les-acteurs/#entry721717 Source (FR)]). | * If the argument akItem is a keyword and the object reference is an actor this function will fail to operate properly. A solution is to transfer the contents of the actor's inventory to a container and call the function on that container ( [http://forums.bethsoft.com/topic/1441239-cant-getitemcount-on-the-pc-via-formlist-of-keywords/page__pid__22196680#entry22196680/ Source (EN)] - [http://forum.wiwiland.net/index.php?/topic/54019-getitemcount-fonctionne-sur-les-conteneurs-mais-pas-les-acteurs/#entry721717 Source (FR)]). | ||
* | * In all cases, if the object reference contains CK-Defined Leveled lists of items then this function will fail to operate properly ([http://forums.bethsoft.com/topic/1444477-about-addressing-the-follower-bow-issue/ Source]) | ||
* If the argument akItem is a keyword and the object reference contains CK-defined items then this function will fail to operate properly ([http://forums.bethsoft.com/topic/1441239-cant-getitemcount-on-the-pc-via-formlist-of-keywords/page__view__findpost__p__22215007 Source]). | * If the argument akItem is a keyword and the object reference contains CK-defined items (Object References) then this function will fail to operate properly ([http://forums.bethsoft.com/topic/1441239-cant-getitemcount-on-the-pc-via-formlist-of-keywords/page__view__findpost__p__22215007 Source]) : it fails to include the CK-defined inventory when GetItemCount tries to calculate its count. | ||
*Calling this function on an objectreference from the outside of its cell will return 1 in the case of the passed in form being in a leveled list. Needs more testing.. but works fine if the player is in the same cell. | |||
== See Also == | == See Also == | ||
Line 42: | Line 44: | ||
*[[AddItem - ObjectReference]] | *[[AddItem - ObjectReference]] | ||
*[[RemoveItem - ObjectReference]] | *[[RemoveItem - ObjectReference]] | ||
*[[GetNumItems - ObjectReference]] |
Latest revision as of 03:26, 3 June 2016
Member of: ObjectReference Script
Returns how many of the specified item is in this reference's inventory.
Syntax[edit | edit source]
int Function GetItemCount(Form akItem) native
Parameters[edit | edit source]
- akItem: The item to look for in this reference's inventory.
- If a reference, will look for just that particular reference.
- If a base object (like armor or a weapon), it will count the how many instances of that base object are in the container
- If a form list, it will count how many of each item in the form list is in the container and sum it all up
- If a keyword, it will count how many items with that keyword are in the container
Return Value[edit | edit source]
How many of said item is in this reference's inventory.
Examples[edit | edit source]
if (Game.GetPlayer().GetItemCount(WeapTypeSwordKeyword) == 0)
Debug.Trace("Player has no swords")
endIf
if (Game.GetPlayer().GetItemCount(SuperSecretPotionReference) == 0)
Debug.Trace("Player doesn't have the super-secret potion")
endIf
Notes[edit | edit source]
- If the argument akItem is a keyword and the object reference is an actor this function will fail to operate properly. A solution is to transfer the contents of the actor's inventory to a container and call the function on that container ( Source (EN) - Source (FR)).
- In all cases, if the object reference contains CK-Defined Leveled lists of items then this function will fail to operate properly (Source)
- If the argument akItem is a keyword and the object reference contains CK-defined items (Object References) then this function will fail to operate properly (Source) : it fails to include the CK-defined inventory when GetItemCount tries to calculate its count.
- Calling this function on an objectreference from the outside of its cell will return 1 in the case of the passed in form being in a leveled list. Needs more testing.. but works fine if the player is in the same cell.