ID:171899
 
I was just wondering How I would be able to get a list of a players contents or inventory. Meaning, I'd want a way to figure out how many obj are in the contents and a way to assign each item a variable. like first item = var/item1 etc.

So, is there a way to do this?

Troglodyte wrote:
I was just wondering How I would be able to get a list of a players contents or inventory. Meaning, I'd want a way to figure out how many obj are in the contents and a way to assign each item a variable. like first item = var/item1 etc.

So, is there a way to do this?


Yeah there is. Use the list.len variable.

EG:
src << "You have got [src.contents.len] items in your inventory"


For the second question, I'm not really sure what you meant,
but you can't _give_ a variable to it, but you can edit one.

EG:
for(var/obj/item/I in src.contents) // only find items
I.variable = "blah"


I'm not sure if this is what you asked because you didn't give enough info about the second question.

~~> Dragon Lord