Can you iterate through an inventory?

Post » Sun Jun 24, 2012 2:29 am

I need a way to iterate through an NPC's inventory and add up the monetary values of all of the items.

I'm considering making a little salesman guy who walks around with you like a follower, but does not participate in combat. What you can do is give him junk, which you can tell him to go to town and sell. He walks away for a while (goes to whiterun I suppose) and sells it off, then 24 hours later he shows up and gives you most of the money you would have made. Basically it just prevents player from having to constantly run back to town to hawk off loot.

I guess another way to do this would be to simply get the monetary value any time an item enters his inventory and add them all up that way. Dunno. Any thoughts?
User avatar
Lily Something
 
Posts: 3327
Joined: Thu Jun 15, 2006 12:21 pm

Post » Sun Jun 24, 2012 1:34 pm

No way I know of to cycle through inventories...you're gonna have to do it with OnContainerChanged or something.
User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm

Post » Sun Jun 24, 2012 12:24 am

You could cycle through a formlist, but you would have to put everything you want checked in that form list. And that would be very slow. And would not work on items from other mods.
User avatar
TOYA toys
 
Posts: 3455
Joined: Sat Jan 13, 2007 4:22 am

Post » Sun Jun 24, 2012 5:05 am

No way I know of to cycle through inventories...you're gonna have to do it with OnContainerChanged or something.

Thanks, I think that'll work.
User avatar
rebecca moody
 
Posts: 3430
Joined: Mon Mar 05, 2007 3:01 pm

Post » Sun Jun 24, 2012 4:22 am

I thought I saw a topic today that mentioned an idea having to do with:

* RemoveAllItems(NewContainer)
*OnItemAdded on the new container
* adding to Arrays/Formlists
User avatar
Andrew Lang
 
Posts: 3489
Joined: Thu Oct 11, 2007 8:50 pm

Post » Sun Jun 24, 2012 3:49 pm

I thought I saw a topic today that mentioned an idea having to do with:

* RemoveAllItems(NewContainer)
*OnItemAdded on the new container
* adding to Arrays/Formlists

But then you've gotta get them to put their clothes back on after you reverse the process...
User avatar
Dean Brown
 
Posts: 3472
Joined: Fri Aug 31, 2007 10:17 pm

Post » Sun Jun 24, 2012 4:22 am

Damn NPCs... why are they all closet streakers?!?

After actually reading the first post, I have a suggestion:

1. Dialogue with salesman ends with 'CustomChest.Activate(Game.GetPlayer())'
2. Custom chest has script attached with OnItemAdded
3. The script keeps a running total of the value added using http://www.creationkit.com/GetGoldValue_-_Form
4. The salesman leaves, comes back later with a random amount of gold less than total value
User avatar
Josee Leach
 
Posts: 3371
Joined: Tue Dec 26, 2006 10:50 pm

Post » Sun Jun 24, 2012 8:46 am

If you use an 'outfit', it does not get removed from an NPC using removeallitems. At least it did not on my NPC. :lol:
User avatar
Matthew Aaron Evans
 
Posts: 3361
Joined: Wed Jul 25, 2007 2:59 am

Post » Sat Jun 23, 2012 11:28 pm

If you use an 'outfit', it does not get removed from an NPC using removeallitems. At least it did not on my NPC. :lol:

Well that would help this guy, but not the other fella...he's knocking out and robbing random NPCs, and he wanted it so if he left them clothing, they would keep it on after the "wake up" routine did this:

Strip the NPC of whatever he had left and hide it in a box temporarily.
Ressurect the NPC (he temporarily "Killed" them to simulate a knockout)
Destroy the respawned gear that was on the NPC (So you couldn't use this to get an unlimited supply of respawned gear)
Returned the NPC's gear to him.

he would then need to catch the OnContainerChanged for any clothing items, and force the NPC to wear them.
User avatar
Sammykins
 
Posts: 3330
Joined: Fri Jun 23, 2006 10:48 am

Post » Sun Jun 24, 2012 6:40 am

Oh guys, you don't have to worry about me anymore. I finished this mod already. Here it is.

http://skyrim.nexusmods.com/downloads/file.php?id=13508
User avatar
Nadia Nad
 
Posts: 3391
Joined: Thu Aug 31, 2006 3:17 pm

Post » Sun Jun 24, 2012 9:43 am

I thought I saw a topic today that mentioned an idea having to do with:

* RemoveAllItems(NewContainer)
*OnItemAdded on the new container
* adding to Arrays/Formlists

Mod looks great! Is this the method you used?

I want to do a quest where you lose all your stuff, but you can get most of it back. I guess I should take a look at the jail scripts.
User avatar
JESSE
 
Posts: 3404
Joined: Mon Jul 16, 2007 4:55 am

Post » Sun Jun 24, 2012 2:48 pm

or the one... part ... of the main quest... where that happens anyways...
User avatar
Pixie
 
Posts: 3430
Joined: Sat Oct 07, 2006 4:50 am

Post » Sun Jun 24, 2012 5:28 am

Yes...Got it......understood...

Spoiler
*cough*party*cough*
User avatar
DAVId Bryant
 
Posts: 3366
Joined: Wed Nov 14, 2007 11:41 pm

Post » Sun Jun 24, 2012 2:15 pm

Yes...Got it......understood...

Spoiler
*cough*party*cough*

or...um...

Spoiler
*Cough*Any Arrest Event*Cough*
User avatar
Verity Hurding
 
Posts: 3455
Joined: Sat Jul 22, 2006 1:29 pm

Post » Sun Jun 24, 2012 1:14 pm

Yes, I should have been more clear on what I meant by jail scripts.
User avatar
Alisha Clarke
 
Posts: 3461
Joined: Tue Jan 16, 2007 2:53 am


Return to V - Skyrim