Hello Lua experts,
Can “userdata” items created by Lua/Corona be stored in a standard table for organization and eventual cleanup? I am loading some sounds into memory using the audio API and "audio.loadSound( 'file' )"
. When I use a local variable (pointer) in the assignment of that, and then print its value to the terminal afterward, it is a “userdata” item, i.e. "userdata: 0x1ee82db0"
What I would like to do is to load several sounds into memory (around 10 of them). These sounds will be played frequently and thus I want to keep them in memory. For organization purposes, I would like to store the Lua references to them (the “userdata” references) in a standard holding table, for example…
local coreSounds = {}
coreSounds[1] = audio.loadSound( 'file' )
coreSounds[2] = audio.loadSound( 'file' )
--etc.
So is it allowable to store “userdata” items in a holding table just like you can with other tables, variable, strings, etc.? If so, can I later loop through this table by the count of its children (in reverse order), and dispose of the audio in that manner?
I’m actually not clear on what “userdata” entails in Lua, or how it compares to standard tables. Any help clarifying this is appreciated.
Brent Sorrentino
Ignis Design
[import]uid: 9747 topic_id: 23754 reply_id: 323754[/import]