I've created a for loop, to create questions the user defined number of times. Here is my code:
[CODE]local Question = {}
for i=1, HelpNPC.NumberOfQuestions do
Question[i] = vgui.Create("DButton", frame)
Question[i]:SetSize(580,40)
Question[i]:SetFont("Questions")
Question[i]:SetTextColor(HelpNPC.TextColor)
Question[i].Paint = function(s, w, h)
draw.RoundedBox(5,0,0,w,h,HelpNPC.SecondaryColor)
end
end [/CODE]
(Anything beginning with HelpNPC is a variable that is created further up btw).
I was wondering, is there a way to set the position inside the for loop so that it increases dynamically?
Like, rather than putting:
[CODE]Question[1]:SetPos(580,100)
Question[2]:SetPos(580,200)
Question[3]:SetPos(580,300)[/CODE]
and so on...
Would there be a way to create this inside the for loop, so that it would increase by, for example, 50 each time? Thanks.
Use a layout element or do 530 + (50 * i)
[QUOTE=Klaes4Zaugen;51262758]Use a layout element or do 530 + (50 * i)[/QUOTE]
Thanks Pat
Sorry, you need to Log In to post a reply to this thread.