gerg357 Posted October 21, 2017 Share Posted October 21, 2017 I'm looking for how to get a chests item list and sell a item randomly and give player the gold value of the item So in shortIt gets items in chest makes a list gets one at random and gives you the gold of its value I've seen this before listed but couldn't find it. Thx guys Link to comment Share on other sites More sharing options...
JonathanOstrus Posted October 22, 2017 Share Posted October 22, 2017 You can only do that if you use and require SKSE. See the https://www.creationkit.com/index.php?title=ObjectReference_Script page Specifically you'll need to get and then loop withGetNumItems()GetNthForm(Int index) Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 22, 2017 Share Posted October 22, 2017 You will need a loop too but is.... ; Returns all base forms from the container into a new array Form[] Function GetContainerForms() native ...is a SKSE code that is missing from the Creation Kit wikki It will return none forms (things like LVI) be sure to cast appropriately. Yes there is more missing than that, be sure to keep checking your Source Files Link to comment Share on other sites More sharing options...
foamyesque Posted October 22, 2017 Share Posted October 22, 2017 Getting the gold value of an item's actually a real pain. Getting the base gold value is easy, but if it is an enchanted item there's no simple way to do it, and if it's player-made things can get really weird. Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 22, 2017 Share Posted October 22, 2017 (edited) Deleted Edited October 22, 2017 by PeterMartyr Link to comment Share on other sites More sharing options...
gerg357 Posted October 22, 2017 Author Share Posted October 22, 2017 So unless I use skse I'm out of luck Link to comment Share on other sites More sharing options...
JonathanOstrus Posted October 22, 2017 Share Posted October 22, 2017 So unless I use skse I'm out of luck Correct. You cannot get any sort of listing of what's in a container without using SKSE functions. The only non SKSE function that I can think of off-hand that is partially relevant is GetItemCount() which requires you to specify which form to check. You can specify a form list of forms to get a summed count. So you could ask the game if the container has, and how many potatoes are in it. But there's no vanilla function to get a list of what the container holds. Link to comment Share on other sites More sharing options...
gerg357 Posted October 22, 2017 Author Share Posted October 22, 2017 Gotcha thanks Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 22, 2017 Share Posted October 22, 2017 Actually, if you don't mind some manipulation you could perform the following non-skse method to obtain a list of items in a container. Place a hidden inaccessible container in the game (could be under the ground but I prefer having it in its own inaccessible cell).When you want to know what is within a specific in-game accessible container, transfer the contents to your hidden container with RemoveAllItems.The hidden container will then use the OnItemAdded event to add each incoming form to an empty formlist.Once complete, send the items back to the original container.Then use RandomInt to pick a value between 0 and one less than the count of entries on the formlist, use that value as the index to an object on the formlist.Retrieve the object from the formlist and get whatever information you need from it.When done with the formlist, use Revert to empty it so that you can start off with a clean empty formlist on the next time around. Link to comment Share on other sites More sharing options...
Recommended Posts