Storyboard, hideOverlay and passing parameters back

Is there a way when you are hiding an overlay via hideOverlay to pass parameters back to the parent scene that can then be picked up in the overlayEnded event listener?

I have an overlay I would like to show that picks up some user input and I would like that passed back to the calling scene. [import]uid: 92150 topic_id: 30229 reply_id: 330229[/import]

I’m sure this is the completely wrong way to go about this, but I can pass the parent scene in the parameters to the overlay, modify a variable in the overlay tied to the scene that was passed and then close the overlay and it will show up in the parent scene:

--------parent scene --------------  
local storyboard = require("storyboard")  
local scene = storyboard.newScene()  
  
local function openOverlay()  
 local options = {  
 params = { parent\_scene = scene }  
 }  
 storyboard.showOverlay("myoverlay", options)  
end  
  
function scene:createScene(event)  
end  
  
--other functions  
  
function scene:overlayEnded(event)  
 print(self.my\_new\_var) end  
------other parent scene code here to make scene show-----  
-----------------------------------------  
  
--------------Overlay scene snippet----------------  
local storyboard = require("storyboard")  
local scene = storyboard.newScene()  
  
local parent\_scene = nil  
  
local function closeOverlay()  
 parent\_scene.my\_new\_var = "TESTING"  
 storyboard.hideOverlay()  
 return true  
end  
function scene:createScene(event)  
 local group = self.view  
 parent\_scene = event.params.parent\_scene  
  
 ----extra stuff below  
end  
return scene  
-------------------end overlay snippet-----------  

Thoughts on this approach? Sounds highly wrong as it would be passing the whole scene object to the overlay. That screams memory problems. Any better ways to accomplish this?
[import]uid: 92150 topic_id: 30229 reply_id: 121097[/import]

I’m sure this is the completely wrong way to go about this, but I can pass the parent scene in the parameters to the overlay, modify a variable in the overlay tied to the scene that was passed and then close the overlay and it will show up in the parent scene:

--------parent scene --------------  
local storyboard = require("storyboard")  
local scene = storyboard.newScene()  
  
local function openOverlay()  
 local options = {  
 params = { parent\_scene = scene }  
 }  
 storyboard.showOverlay("myoverlay", options)  
end  
  
function scene:createScene(event)  
end  
  
--other functions  
  
function scene:overlayEnded(event)  
 print(self.my\_new\_var) end  
------other parent scene code here to make scene show-----  
-----------------------------------------  
  
--------------Overlay scene snippet----------------  
local storyboard = require("storyboard")  
local scene = storyboard.newScene()  
  
local parent\_scene = nil  
  
local function closeOverlay()  
 parent\_scene.my\_new\_var = "TESTING"  
 storyboard.hideOverlay()  
 return true  
end  
function scene:createScene(event)  
 local group = self.view  
 parent\_scene = event.params.parent\_scene  
  
 ----extra stuff below  
end  
return scene  
-------------------end overlay snippet-----------  

Thoughts on this approach? Sounds highly wrong as it would be passing the whole scene object to the overlay. That screams memory problems. Any better ways to accomplish this?
[import]uid: 92150 topic_id: 30229 reply_id: 121097[/import]

Interested to know if there are alternatives as well. =) [import]uid: 70056 topic_id: 30229 reply_id: 138652[/import]

Interested to know if there are alternatives as well. =) [import]uid: 70056 topic_id: 30229 reply_id: 138652[/import]

You can do it like this. From the overlay scene set a parameter to non overlay scene.

[lua]local non_overlay_scene = storyboard.getScene( ‘non_overlay_scene’ )
non_overlay_scene.whatToDo = ‘test’[/lua]

And from your non_overlay_scene.lua file which is the non overlay scene you can access that whatToDo from the scene object as follows.

[lua]local scene = storyboard.newScene()
–[[



]]–
function scene:overlayEnded( event )
print(scene.whatToDo)  – This will print ‘test’ to the console
end

scene:addEventListener( “overlayEnded” )
[/lua]

You can do it like this. From the overlay scene set a parameter to non overlay scene.

[lua]local non_overlay_scene = storyboard.getScene( ‘non_overlay_scene’ )
non_overlay_scene.whatToDo = ‘test’[/lua]

And from your non_overlay_scene.lua file which is the non overlay scene you can access that whatToDo from the scene object as follows.

[lua]local scene = storyboard.newScene()
–[[



]]–
function scene:overlayEnded( event )
print(scene.whatToDo)  – This will print ‘test’ to the console
end

scene:addEventListener( “overlayEnded” )
[/lua]