Jump to content

OBSE GetItems and the Array


firedog118

Recommended Posts

OBSE has a function called 'GetItems' which returns all the items in either the player's or a container's inventory.

It returns the data in the form of an Array. And I understand the basics of an Array, but I can't work out how to read from an Array.

 

So any help would be appreciated.

Link to comment
Share on other sites

You have to define your array first, and then use the getitems to dump your inventory into it. Once it is there.....

 

arrayvariablename [0] will have the first item

arrayvariablename [1] will have the second item

 

Etc.....

 

If you have a bunch of stuff in your inventory, there will be a big array generated. Seems you can restrict what it dumps to the array though, by item 'type', be it weapons, armor, whathaveyou. (you can do up to ten different types....)

 

What specifically are you looking for?

Link to comment
Share on other sites

Well, in order to store that array you should do something like

 

let InvArr := ActorOrContainer.GetItems

 

Then all the items in the actor or container's inventory will be stored in the array InvArr. This is an array of type array, meaning that the index is of integer form. So InvArr[0], InvArr[1], InvArr[2] all refer to different elements in the array. InvArr[0.3], InvArr["FirstItem"], etc would be invalid elements.

 

If you want to do things to the items in the array, you can use a while loop.

 

while (index < ar_size InvArr)
let tempref := InvArr[index]
;	do stuff to tempref, which is an item in the array
let index := index + 1
loop

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...