Looping through a button, guide.

Hello Facepunch,

I’m having trouble lately trying to figure out how to do a specific method, if someone could guide me/give me an example just to raise me off my feet i’d appreciate it a lot.
What I’m trying to do is an inventory, not the the whole meta structre sor but it’s simply used with a darkrp function which returns the players items in his pockets. I’ve decided to make something off this where i can retrieve the players items, and then list them just on derma.

The issue I’m having though is making the ietms buttons, I want the items to specifically be buttons so i can click then use other buttons on the panel to remove/give/use. What I’m aiming for a list, the list belows shows how the contents I want to be displayed, but the issue really is just making the items buttons, so instead of doing in the written example below they should in theory every item be buttons.
x1 Bacon
x6 Lockpicks

I’m not entirely sure, but if someone could assist me with this I’d apprecaite it a lot. Excuse my poor code.
plrPocket = {} – the players pocket
plrPocket[1] = “Mars Bar” – contents in his pocket as an example…
plrPocket[2] = “Lockpick”

– What’s the best way of showing his items, but alot making them buttons too?
– here what I got.

for i=1, 2 ( plrPocket ) do
i – we create a button
i – somehow we need to grab the players item name?



Thank you, I hope this makes sense, I appreciate all of your help.

I helped a person with the same question earlier, you could probably learn from this thread: http://forum.facepunch.com/showthread.php?t=1535757

Thank you, I’ll take a look!