Jump to content

Get value of all items in a container?


grigoriprime

Recommended Posts

I'm pretty sure the answer to this is simply "no" but is there a way to have a script get the total (base) value of all items in a container?

 

I'd prefer not to require FOSE but I know that does have a GetItemValue function. From what I see on the documentation for it though, it wouldn't be practical (or even really possible) to do this for all items in a container. I had also considered "dumping" the items into a leveled list but I don't think that would make this possible either.

 

It's for a player merchant type thing and I wanted to use "total value of items / item count" as a variable in a calculation.

 

I figured out a different way to do what I originally intended; but if this is possible it would allow me to do a much more dynamic and "real time feeling" player interaction.

Link to comment
Share on other sites

no

 

:D

 

I'm not sure I understand what you meant in your second post, as for the first one, the only practical way I can think of is by iterating through the items in the container using Label and Goto. This of course requires FOSE.

 

Simply use an int variable as the index following a structure similar to this one:

int index
int numitems 	;used to store the total number of unique items in the container, which you can retrieve with the GetNumItems function.
int count 	;used to temporarily store the number of copies of any given item to calculate the value, which you can retrieve using GetItemCount.
float value
float totalvalue
ref item

Label 1

if index < numitems
	set item to ContainerREF.GetInventoryObject index
	set count to ContainerREF.GetItemCount item
	set value to ( GetItemValue item ) * count
	set totalvalue to totalvalue + value
	;do stuff
	set index to index + 1
	Goto 1
endif
I hope that helps. Edited by claustromaniac
Link to comment
Share on other sites

Yes, that's incredibly helpful.

 

I think the workaround I came up with for calculating the daily income of the store is actually still a better option but the script you provided is immensely useful in figuring out how I'm going to distinguish between "things you are selling through the store" and "things which the store now always sells" as well as how my original idea of using a dynamic leveled list for "storage" may work out after all. Basically things like consumables and ammo (items added to leveled list) need to be handled differently than things like weapons and armor (items themselves added to merchant container). This is like... way more than half of what I needed to figure out so thanks thanks...

 

THANKS!

 

P.S. Basically i changed the way multipliers are used on a 1-99 base random number. It works out to a 2 through 5,940 range depending on modifiers including total number of items sold (and now maybe also total value if I hook FOSE).

Link to comment
Share on other sites

Very glad to help.

 

I'm sorry to say most of what you're saying sounds like gibberish to me, most likely because I'm not fully aware of what kind of mod you're working on, and maybe also because I'm not fully awake, but if it involves a store it sure sounds interesting to me already. I'll keep an eye on you :ninja:

 

Happy modding!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...