Jump to content

[LE] Possible to get inventory items listed in an array?


Recommended Posts

As it states, I'm wondering if it's possible to make an array that reads all of the players current inventory items(not just equipped). If so, arrays aren't my strong point, how would I go about this?

Link to comment
Share on other sites

As it states, I'm wondering if it's possible to make an array that reads all of the players current inventory items(not just equipped). If so, arrays aren't my strong point, how would I go about this?

 

Simplest way is the SKSE function GetContainerForms(). You can manually do so by iterating calls with the SKSE function GetNthForm(), but that's both more coding and much slower. You can finally do a completely non-SKSE approach through transferring inventory back and forth with a dummy chest and listening for OnItemAdded()/OnItemRemoved() events, but that's very slow and somewhat unreliable.

Link to comment
Share on other sites

I thank you for the quick reply, of the two, which do you think would be more favorable. The way I'm setting it up the player should never have more than ~40 items at one time

Link to comment
Share on other sites

I thank you again. I suppose it'd be near impossible to get the container listed as selectable message box options, huh

 

-Edit, it seems GetNthForm may be what I'm looking for. Or is that the same thing lol

 

-Edit 2, I'm retarded and way overcomplicating and overthinking what I needed to use this for. Sorry for wasting your time. I have it working perfectly now.

Edited by Rizalgar
Link to comment
Share on other sites

 

As it states, I'm wondering if it's possible to make an array that reads all of the players current inventory items(not just equipped). If so, arrays aren't my strong point, how would I go about this?

 

Simplest way is the SKSE function GetContainerForms(). You can manually do so by iterating calls with the SKSE function GetNthForm(), but that's both more coding and much slower. You can finally do a completely non-SKSE approach through transferring inventory back and forth with a dummy chest and listening for OnItemAdded()/OnItemRemoved() events, but that's very slow and somewhat unreliable.

 

 

If at all possible I would use GetContainerForms, and then do any searching needed by operating on the array. It has a bunch of speed advantages, the code is simpler, and the data isn't volatile (i,e. the array won't change while you work on it except by what your script is doing; if you operate directly on the player's inventory, they can pick up, use, or drop items while your script is processing, which can confuse it),

Link to comment
Share on other sites

  • Recently Browsing   0 members

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