How to create buttons/objects/variables dynamically in a loop in Lua?

So the challenge I am having is creating variable names dynamically:

Lets say I need 500 buttons:

x = 0
For Loop Begin
x = x + 1

local button…x = ui.newButton{ (I need button1, button2, button3 how???)
–blah blah
}
For Loop End
[import]uid: 38453 topic_id: 7316 reply_id: 307316[/import]

put them in a table

local buttons = {} for i = 1, 10 then buttons[#buttons+1] = ui.newButton() end [import]uid: 12108 topic_id: 7316 reply_id: 25696[/import]

That worked great!

Thanks a lot. I wish I knew Lua game development best practices better!

[import]uid: 38453 topic_id: 7316 reply_id: 25720[/import]

did you read the corona docs and the Lua manual jinibot? :stuck_out_tongue: [import]uid: 6645 topic_id: 7316 reply_id: 25799[/import]