GetInventoryObject
Revision as of 18:33, 19 November 2007 by imported>Haama (→Notes: Updates and notes on order and loading)
A function for Oblivion Script Extender
Syntax:
GetInventoryObject index
Must be called on a reference. Returns the indexth item in the container's inventory.
Example
ref itemType set itemType to ( player.GetInventoryObject 0 ) container.additem itemType 1
Finds the first item in the player's inventory, and adds an object of the same type to a container.
Notes
- Objects are listed in the order they were first picked up. If you pick up a sword, a bow, and a shield, GetInventoryObject 0 will return the sword, 1 will return the bow, and 2 the shield.
- Items remember what order they were in, so if you dropped the bow and picked it up again, it will still be returned by GetInventoryObject 1, and the shield will still be 2.
- However, every time you load a save game the order will be reversed. The only exceptions are the items on the Player base object (default LowerPants05, LowerShirt05, LowerShoes05, WristIrons)
- Like GetNumItems, this works with unique items - if your 4th item was an arrow, and you have ten of them, GetInventoryItemType 3 (it starts with 0, 3 is the fourth value) will return Iron Arrow, and GetInventoryItemType 4 will return whatever is next, not another Iron Arrow.
- Prior to OBSE v0006, this function was known as GetInventoryItemType.
- Using this function every frame will significantly drop FPS (by 3 on my semi-old computer). If you need to run it constantly, try to find an alternative (i.e., linked lists of reference variables to the items and if (SomeNPC.GetItemCount pInvObj)), or only run it every few frames (5 or more). Note that this only applies to using the function every few frames, a 1000 of them in a single frame will take less than a second to run.
- As of v0013 this function is much faster. Still not advisable to run 50 of them a frame, but 1 a frame won't cause an FPS drop. See this post for some stats.