Rizalgar Posted May 23, 2019 Share Posted May 23, 2019 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 More sharing options...
foamyesque Posted May 23, 2019 Share Posted May 23, 2019 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 More sharing options...
Rizalgar Posted May 23, 2019 Author Share Posted May 23, 2019 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 More sharing options...
Evangela Posted May 23, 2019 Share Posted May 23, 2019 I would choose speed over complexity so: GetContainerForms() Link to comment Share on other sites More sharing options...
Rizalgar Posted May 23, 2019 Author Share Posted May 23, 2019 (edited) 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 May 23, 2019 by Rizalgar Link to comment Share on other sites More sharing options...
foamyesque Posted May 23, 2019 Share Posted May 23, 2019 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 More sharing options...
Recommended Posts