Difference between revisions of "GetInventoryObject"
Jump to navigation
Jump to search
imported>WarMachineDD7 (Created page with "{{Function |origin = FOSE1 |summary = Returns the base form of the nth form in a container. |name = GetInventoryObject |alias = GetNthObject |returnType = ref |reference...") |
imported>Odessa m |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Function | {{Function | ||
|origin = FOSE1 | |origin = FOSE1 | ||
|summary = Returns the base form of the | |summary = Returns the base form of the Nth item in a container. | ||
|name = GetInventoryObject | |name = GetInventoryObject | ||
|alias = GetNthObject | |alias = GetNthObject | ||
|returnType = | |returnType = baseform | ||
|referenceType = | |referenceType = Container | ||
|arguments = | |arguments = | ||
{{FunctionArgument | {{FunctionArgument | ||
|Name = index | |Name = index | ||
|Type = int | |Type = int | ||
}} | }}}} | ||
==Example== | |||
<pre> | |||
ref rItem | |||
set rItem to PlayerREF.GetInventoryObject 21 | |||
</pre> | |||
Often you may wish to use this in a loop, to go through every item in an inventory: | |||
<pre> | |||
int x | |||
ref rItem | |||
let x := PlayerREF.GetNumItems | |||
while x > 0 | |||
let x -= 1 ; decrement x, the first item is '0' | |||
let rItem := PlayerREF.GetInventoryObject x | |||
; do something | |||
loop | |||
</pre> | |||
==Notes== | ==Notes== | ||
* | *Beware removing items from a container within a loop, because it may change the index of those later. | ||
*Multiple instances of the same base form in a container are considered as just one item by the function. | *Multiple instances of the same base form in a container are considered as just one item by the function. | ||
[[Category:Functions_(FOSE) | ==See Also== | ||
*[[ForEach]] | |||
*[[GetNumItems]] | |||
*[[GetEquippedObject]] | |||
*[[GetRefs]] | |||
*[[while]], [[let]] | |||
*[[ShowInventory]] / [[Con_Inv]] | |||
[[Category:Functions_(FOSE)]] |
Latest revision as of 10:54, 14 September 2014
< [[::Category:Functions|Category:Functions]]
A function added by the Fallout Script Extender.
Description
Returns the base form of the Nth item in a container.
Syntax
(baseform) Container.GetInventoryObject index:int
Or:
(baseform) Container.GetNthObject index:int
Example
ref rItem set rItem to PlayerREF.GetInventoryObject 21
Often you may wish to use this in a loop, to go through every item in an inventory:
int x ref rItem let x := PlayerREF.GetNumItems while x > 0 let x -= 1 ; decrement x, the first item is '0' let rItem := PlayerREF.GetInventoryObject x ; do something loop
Notes
- Beware removing items from a container within a loop, because it may change the index of those later.
- Multiple instances of the same base form in a container are considered as just one item by the function.