Difference between revisions of "GetNumItems"
Jump to navigation
Jump to search
imported>Haama (Added to Functions category) |
imported>Quetzilla |
||
(2 intermediate revisions by one other user not shown) | |||
Line 2: | Line 2: | ||
'''Syntax:''' | '''Syntax:''' | ||
GetNumItems | (numItems:short) [''ref.'']GetNumItems | ||
Must be called on a reference. Returns the number of unique items in the | Must be called on a reference. Returns the number of unique items in the reference's inventory. | ||
==Notes== | ==Notes== | ||
Line 12: | Line 12: | ||
*Equipped items and identical items that are unequipped are still only one unique item | *Equipped items and identical items that are unequipped are still only one unique item | ||
*Using this function every frame will significantly drop FPS. The more items that have to be scanned, the worse it is (i.e., 1 item a frame will drop it by 3, 15 by 25). Use this function only when necessary, and try to avoid using it in [[GameMode]]. | *Using this function every frame will significantly drop FPS. The more items that have to be scanned, the worse it is (i.e., 1 item a frame will drop it by 3, 15 by 25). Use this function only when necessary, and try to avoid using it in [[GameMode]]. | ||
**There are several ways to use [[GetInventoryObject]] instead of '''GetNumItems''' (keep in mind that it is also CPU-heavy, but not as much) | **There are several ways to use [[GetInventoryObject]] instead of '''GetNumItems''' (keep in mind that it is also CPU-heavy, but not as much) | ||
**v0013 significantly improves the efficiency of this function | |||
If you need to test if a container has items in it, use | If you need to test if a container has items in it, use | ||
ref pInvObj | ref pInvObj | ||
Line 26: | Line 28: | ||
set InvTotal to SomeContainer.GetNumItems | set InvTotal to SomeContainer.GetNumItems | ||
else | else | ||
set pInvObj (SomeContainer.GetInventoryObject InvTotal) | set pInvObj to (SomeContainer.GetInventoryObject InvTotal) | ||
if pInvObj | if pInvObj | ||
... | ... | ||
== See Also == | |||
* [[GetInventoryObject]] | |||
[[Category: Functions]] | [[Category: Functions]] | ||
Line 35: | Line 39: | ||
[[Category: Inventory Functions]] | [[Category: Inventory Functions]] | ||
[[Category: Inventory Functions (OBSE)]] | [[Category: Inventory Functions (OBSE)]] | ||
Latest revision as of 15:29, 11 April 2008
A command for Oblivion Script Extender
Syntax:
(numItems:short) [ref.]GetNumItems
Must be called on a reference. Returns the number of unique items in the reference's inventory.
Notes[edit | edit source]
- Note that it is the number of unique items in the inventory - 10 arrows will only count as one item.
- Gold counts as an item, so if you have any gold, you'll get a +1 to your return
- Equipped items and identical items that are unequipped are still only one unique item
- Using this function every frame will significantly drop FPS. The more items that have to be scanned, the worse it is (i.e., 1 item a frame will drop it by 3, 15 by 25). Use this function only when necessary, and try to avoid using it in GameMode.
- There are several ways to use GetInventoryObject instead of GetNumItems (keep in mind that it is also CPU-heavy, but not as much)
- v0013 significantly improves the efficiency of this function
If you need to test if a container has items in it, use
ref pInvObj ... set pInvObj to (SomeContainer.GetInventoryObject 0) if pInvObj ...
If you need to see if the player has a new item, use GetNumItems once and then GetInventoryObject
ref pInvObj short InvTotal ... if (InvTotal == 0) set InvTotal to SomeContainer.GetNumItems else set pInvObj to (SomeContainer.GetInventoryObject InvTotal) if pInvObj ...