Can't Scroll To Other Guns

I been trying to have all the guns show. but i dont wanna make another tab, i want to be able to scroll down like its a list.

Here is the lua code for it. I need an example or something on how to do it.

http://pastebin.com/raw.php?i=cfkEzUJw

Have you tried using a DScrollPanel instead of a DCollapsibleCategory (unless you want more than one menu in a tab)? Also, I noticed you weren’t using a DIconLayout for the weapons on your list. I might suggest doing that as it will make positioning the icons A LOT easier, as well as using Dock to get your elements in a nice location.

I might provide an example once I have the time.

Thank You MPan1, an example would be great. Thanks :smiley:

[editline]15th May 2015[/editline]

Do I change WeaponsCollapsibleCategory too?

Try changing the code you provided to



        local WeaponsPanel = vgui.Create("DScrollPanel", Mercframe)
        WeaponsPanel:Dock(FILL)
                local num1 = 0


Add the code from before after local num1 = 0 (what you had before, I just snipped it to keep this short)
Tell me what it looks like.

the guns scroll up but everything stays the same. I’m able to purchase everything now. but it looks ugly. but i can fix

[editline]15th May 2015[/editline]

Thanks a bunch!

[editline]15th May 2015[/editline]

Anyways to have everything move at once?

Try doing something like



local WeaponsPanel = vgui.Create("DScrollPanel", Mercframe)
WeaponsPanel:Dock(FILL)

local List = vgui.Create( "DIconLayout", WeaponsPanel ) //This is a blank layout by default
List:Dock(FILL) //Change this to SetSize if it looks terrible
List:SetPos( 0, 0 )
List:SetSpaceY( 5 ) //Sets the space in between the panels on the X Axis by 5
List:SetSpaceX( 5 ) //Sets the space in between the panels on the Y Axis by 5

local BuyIcon = List:Add("DModelPanel") //Add something to the layout
	BuyIcon:SetSize(100,90) //Set the size
	//You don't need to set the position, that is done automatically.
end


You will probably need to adapt this to your own code, I’m not really able to do it myself and test it because your code has a lot of variables (such as Items{}) that you didn’t include. I have a lot of ideas for far simpler methods to get the results you want, but I really need an example with more in it.

Also, try drawing all the parts of one of your buttons on the BuyIcon instead of on the WeaponsPanel (by parenting it, or maybe accessing the Paint() function of it)

I also noticed you were doing a lot of



local Thing = vgui.Create("DModelPanel", WeaponsPanel)
                Thing:SetParent(WeaponsPanel)


When saying



("DModelPanel", WeaponsPanel)


Is the same as



Thing:SetParent(WeaponsPanel)


You probably already knew that.

Sorry for not being very helpful with this post, but it would be so much easier for me to edit if I were able to use it myself. If you included some more tables or variables that you left out in your code until it was run-able, it’d really help.

Thanks Alot. Solved :smiley: