how to save variable data for a scene?

How would one save variable data in a scene, in a way that persists even after a garbage collection.

For example should the “scene.returnButtonScenePath” remain valid across the life of the scene, even if the garbage collector kicks in and purges the scene?

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
scene.returnButtonScenePath = "asdf"  

[import]uid: 140210 topic_id: 26290 reply_id: 326290[/import]

Use globals? It’s difficult to say what gets wiped during a scene purge so globals (or at least a fake global table) seems safest. [import]uid: 41884 topic_id: 26290 reply_id: 106535[/import]

Add it to the storyboard object:

storyboard.returnButtonScenePath = “asdf”

its then available to any storyboard scene.
[import]uid: 19626 topic_id: 26290 reply_id: 106543[/import]

Oh. Sorry, but forgot to point out its for use in my scene baseclass. So when I create a scene from a base class if I need a Return Button I pass this to the base class via the “new” method, the the baseclass stores this.

So here it can’t be shared as a global, as there might be more than one unpurged scene using the approach.

Any suggestions given this?

[import]uid: 140210 topic_id: 26290 reply_id: 106589[/import]

Update: I found the approach I had actually works ok, I just had some listeners in my base class that weren’t marked as “local” and there was some cross-scene issues with them occurring as they would have been global…

So this seems to work:

local scene = SceneBase:new({returnButton = true, returnButtonScene = "views.scenes.3\_darkRoom.3\_darkRoom"})  
SceneBase = {}  
  
 function SceneBase:new(options)  
 local scene = Storyboard.newScene()  
  
 options = options or {}  
 scene.showReturnButton = options.returnButton  
 scene.returnButtonScene = options.returnButtonScene  
   
 return scene  
 end  
  
return SceneBase  
  

[import]uid: 140210 topic_id: 26290 reply_id: 106733[/import]