Any way to save a table as public to all scenes?

Hello,

Is there any way that once I populate a table with some information that I can pass it to another scene without saving it to sqlite or a file? I know I can save other data like composer.setVariable but any way for a table with records in it?

Thanks,

Warren

I think you mean global.  There is no concept of public/private in Lua.  (At least not in the way a C++ or other OOP language uses these terms.)

The answer is yes.  Just store the table reference in a global:

\_G.myStuff = {}

Ah, I mentioned composer’s set/getVariable() to, but then saw you mentioned it.  I’m pretty sure that should work fine, but if not a global will do the trick.  

Note: Globals are not bad.  This is why globals exist.  However, using them accidentally or needlessly is messy/bad.

PS - Don’t forget you can pass arbitrary data via params in gotoScene() also:

https://docs.coronalabs.com/daily/api/library/composer/gotoScene.html#params-optional

I think you mean global.  There is no concept of public/private in Lua.  (At least not in the way a C++ or other OOP language uses these terms.)

The answer is yes.  Just store the table reference in a global:

\_G.myStuff = {}

Ah, I mentioned composer’s set/getVariable() to, but then saw you mentioned it.  I’m pretty sure that should work fine, but if not a global will do the trick.  

Note: Globals are not bad.  This is why globals exist.  However, using them accidentally or needlessly is messy/bad.

PS - Don’t forget you can pass arbitrary data via params in gotoScene() also:

https://docs.coronalabs.com/daily/api/library/composer/gotoScene.html#params-optional