• Creating multiple buttons without remaking the button?
    2 replies, posted
how can i make my DButtons without continuously using [CODE] local btn = vgui.Create("DButton") btn:SetSize() btn.SetPos() btn.DoClick = function() end [/CODE] etc if i wanted to create 24 buttons how would i do this? and can i do it from tables like this... [CODE]button1 = {title = Button 1,sound = sound1.wav} button2 = {title = Button 2,sound = sound2.wav} button3 = {title = Button 3,sound = sound3.wav}[/CODE] If this is something for coderhire tell me
[lua]local buttons = { button1 = { title = "Button 1", sound = sound1.wav }, button2 = { title = "Button 2", sound = sound2.wav }, button3 = { title = "Button 3", sound = sound3.wav } } [/lua] Then [lua]for _, manybuttons in ipairs(buttons) do local btn = vgui.Create("DButton") btn:SetSize(w, h) btn:SetPos(x, y) btn.DoClick = function() end end[/lua]
You could also use vgui.register if you are unsure how many panels you will need to create.
Sorry, you need to Log In to post a reply to this thread.