Accessing inventories in script?

Post » Sun Jun 24, 2012 7:44 am

What I'm trying to is make a script that adds a container's entire inventory to the player, then later it returns *only* what was added by the container back to said container, removing it from the player. My initial idea was to make an array containing a list of items that were in the container originally, along with counts for each item, but I seem to be having trouble.

1) Is it possible to create an array without a fixed length? All of the examples on the wiki show the script initializing the array with a defined length.

2) Is it possible to access an inventory as an array directly? This would be the most perfect approach, by far, but from what I can tell there's no function that returns and array like that in ObjectReference.
User avatar
Connie Thomas
 
Posts: 3362
Joined: Sun Nov 19, 2006 9:58 am

Post » Sun Jun 24, 2012 6:26 am

Container's entire inventory to the player: YourContainerREF.RemoveAllItems(Game.GetPlayer())

Put the item(s) back from whence they came: Are the items from the container found only in that container? If so, you could make a FormList including only the those items, set said iVar = Game.GetPlayer().GetItemCount(YourFLST), then Game.GetPlayer().RemoveItem(YourFLST, iVar, False, YourContainerREF)
User avatar
Anna Krzyzanowska
 
Posts: 3330
Joined: Thu Aug 03, 2006 3:08 am

Post » Sat Jun 23, 2012 7:55 pm

The items in the container could be anything - the player has full access to the container, and is expected to use it for storage even.
User avatar
Rude Gurl
 
Posts: 3425
Joined: Wed Aug 08, 2007 9:17 am

Post » Sun Jun 24, 2012 5:17 am

I meant the items which are to not be returned to the player/removed from player after the second move described. If those aren't unique, you could use http://www.creationkit.com/OnItemAdded_-_ObjectReference and http://www.creationkit.com/OnItemRemoved_-_ObjectReference then add/remove the forms from the FLST with http://www.creationkit.com/AddForm_-_FormList/http://www.creationkit.com/RemoveAddedForm_-_FormList accordingly, ensuring the above stuff would work as desired. Haven't tinkered with arrays yet, so sorry if I'm derailing your topic.
User avatar
Katie Samuel
 
Posts: 3384
Joined: Tue Oct 10, 2006 5:20 am

Post » Sun Jun 24, 2012 10:33 am

Well I did consider using OnItemAdded() on the player. Can you register events on references other than the one the script is attached to?
User avatar
Anna Beattie
 
Posts: 3512
Joined: Sat Nov 11, 2006 4:59 am

Post » Sun Jun 24, 2012 2:03 am

Bump? Anybody have any ideas?
User avatar
Chantel Hopkin
 
Posts: 3533
Joined: Sun Dec 03, 2006 9:41 am


Return to V - Skyrim