• Derma PropertySheet help!
    1 replies, posted
Im only getting 1 icon per tab when there should be 2 icons. [IMG]http://img33.imageshack.us/img33/5279/di07.png[/IMG] Here is my code if you want to look at it... [CODE] local function BuyMenu() local xOffset = ScrW() / 10 local yOffset = 32 local scrWidth = ScrW() local scrHeight = ScrH() - 64 local boardWidth = scrWidth - (2* xOffset) local boardHeight = scrHeight - (2* xOffset) local Printer = {} Printer[1] = "money_printer_bronze" Printer[2] = "money_printe_god" local Other = {} Other[1] = "dispenser" Other[2] = "basic_powerplant" local frame = vgui.Create("DFrame") local IconList = vgui.Create( "DPanelList", frame ) frame:Center() frame:SetPos(10,30) frame:SetSize( boardWidth , boardHeight ) frame:SetTitle("BuyMenu") frame:MakePopup() IconList:EnableVerticalScrollbar( true ) IconList:EnableHorizontal( true ) IconList:SetPadding( 4 ) IconList:SetPos(10,30) IconList:SetSize(200, 160) local PropertySheet = vgui.Create( "DPropertySheet" ) PropertySheet:SetParent( frame ) PropertySheet:SetPos( 5, 30 ) PropertySheet:SetSize( boardWidth - 20, boardHeight - 40 ) local SheetItemOne = vgui.Create( "SpawnIcon", IconList ) for k,v in pairs(Printer) do SheetItemOne:SetModel( v ) IconList:AddItem( icon ) SheetItemOne.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("buy_entity", v) end end local SheetItemTwo = vgui.Create( "SpawnIcon", IconList ) for k,v in pairs(Other) do SheetItemTwo:SetModel( v ) IconList:AddItem( icon ) SheetItemTwo.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("buy_entity", v) end end PropertySheet:AddSheet( "Prienters", SheetItemOne, "gui/silkicons/user", true, true, "Stuff" ) PropertySheet:AddSheet( "Other", SheetItemTwo, "gui/silkicons/group", true, true, "Stuff" ) end usermessage.Hook("BuyMenu", BuyMenu) [/CODE]
You're creating only one with vgui.Create, inside of which you run through your table. Your kv loop needs to contain the vgui.Create, not vice versa. [lua] for k, v in pairs(Printer) do local icon = vgui.Create("SpawnIcon",IconList) icon:SetModel(v) etc end [/lua] Also it doesn't look like you defined the term icon in your IconList:AddItem(icon).
Sorry, you need to Log In to post a reply to this thread.