RemoveItem & FormLists

Post » Tue Jun 19, 2012 5:01 pm

Trying to get a script to remove all items from the player in a specific form list and put them in a container. Currently i've just been passing in 100, hoping the player never has more than that many of each item.


ex:
Game.GetPlayer().RemoveItem(SomeFormList, 100, true, SomeContainer)

My question is how do i make it remove ALL of each item in the list without having to give a specific number of them to remove?

I can get the intended effect by looping through the form list and use GetItemCount() to figure out how many to remove but that is slow as hell.

something like this:
int index = 0

While (index < list.GetSize())

Form f = list.GetAt(index)
int count = Game.GetPlayer().GetItemCount(f)
if(count)
Game.GetPlayer().RemoveItem(f, count, false, somecontainer)
endif
index = index + 1

EndWhile
but like i said, that is stupid slow.

the wiki has this note:
If you pass in a form list, it will remove aiCount of each item in the form list from the container. If there isn't aiCount of a particular item in the container, it will remove all of them.

If i pass in 10, and there's only 9 it will remove all of them. Cool. But if there's 20 and i pass in 10 it only remove 10. How to make it remove ALL everytime?
User avatar
Kyra
 
Posts: 3365
Joined: Mon Jan 29, 2007 8:24 am

Post » Tue Jun 19, 2012 4:56 am

If I remember correctly, you can call http://www.creationkit.com/GetItemCount_-_ObjectReference with a http://www.creationkit.com/FormList_Script to get the total count of all items in the list in that ObjectReference's inventory.

Cipscis
User avatar
Dan Endacott
 
Posts: 3419
Joined: Fri Jul 06, 2007 9:12 am

Post » Tue Jun 19, 2012 6:27 am

From GetItemCount at the wiki:
If a form list, it will count how many of each item in the form list is in the container and sum it all up

Not exact, but i guess it will work.
User avatar
naome duncan
 
Posts: 3459
Joined: Tue Feb 06, 2007 12:36 am

Post » Tue Jun 19, 2012 6:46 am

But, if you have 10 iron ingots, and 10 gold ingots, if your formlist had all the ingots, the GetItemCount would return 20.

Just put in a number like 9999. It really does not matter, it will remove up to that number from the player and place the number removed into the chest.
User avatar
Latino HeaT
 
Posts: 3402
Joined: Thu Nov 08, 2007 6:21 pm

Post » Tue Jun 19, 2012 12:47 pm

It's a working.

The final solution:

int count = Game.GetPlayer().GetItemCount(SomeFormList)
Game.GetPlayer().RemoveItem(SomeFormList, count, true, SomeContainerToStashTo) <---'true' to suppress messages as it will flood the notify area

thanks
User avatar
vanuza
 
Posts: 3522
Joined: Fri Sep 22, 2006 11:14 pm

Post » Tue Jun 19, 2012 9:16 am

But, if you have 10 iron ingots, and 10 gold ingots, if your formlist had all the ingots, the GetItemCount would return 20.

Just put in a number like 9999. It really does not matter, it will remove up to that number from the player and place the number removed into the chest.

Yeah i thought the same thing. Just seems like wasted cycles.

will use the 9999 version.
User avatar
Amy Gibson
 
Posts: 3540
Joined: Wed Oct 04, 2006 2:11 pm

Post » Tue Jun 19, 2012 7:37 am

Actually i went with the GetItemCount version because it gives me the option of playing a different activator sound if items were present or not.
User avatar
Rinceoir
 
Posts: 3407
Joined: Thu Jun 29, 2006 1:54 am


Return to V - Skyrim