Is there a way to send the new scene a parameter?

I was wondering if there is a way to send the scene a parameter in director when I change views.

For instance I have a People Menu that lists first names. When I click on a first name I change scene to a PersonDetail scene. I need the Person Detail to get the id of the person selected from the previous scene is there a clean way to do this?

I wish I could do something like
director:changeScene(“personDetail”, “moveFromLeft”, idForPersonSelected)

But I don’t think you can do that.

Suggestions? Our current idea, that would work but isn’t good design is to just have a currentSelected person field in the database that gets set by the PeopleMenu and checked by the PersonDetail Scene. How would you do it?

Thanks,
Tim
[import]uid: 39480 topic_id: 17561 reply_id: 317561[/import]

You can save the value in another Lua file OR you can make it a global, like this:

[lua]_G.someinfo = 10[/lua]

Then you can recall it in future scenes in the same way.

Peach :slight_smile: [import]uid: 52491 topic_id: 17561 reply_id: 66890[/import]

Dear Peach,

is there a way, instead of using a global var, we use a global function ? Ex. setScore(val)
My function setScore is declared like this in a level.lua file :

function setScore(val)
… inc the score

end

… and i would like to call it from an other file (my class player).

Many thanks in advance,
Best,
Jérôme.
[import]uid: 96703 topic_id: 17561 reply_id: 68549[/import]

To call the function you would do it like this;

[lua]filename.setScore()[/lua]

Using the file name for where the function is.

Make sense? :slight_smile: [import]uid: 52491 topic_id: 17561 reply_id: 68558[/import]

Many thanks :slight_smile:
Best,
Jérôme. [import]uid: 96703 topic_id: 17561 reply_id: 68688[/import]

I have a kind of similar problem, I’m sure its easy so I hope someone can help. I’ve only been using corona for a few weeks now and have decided to make a quiz app. The way I want it to work is after each question is answered the user input, either A, B, C, D or E, is put into an array and at the end of the 10 questions the array index 1 - 10 is checked against another array which has the correct answers in order, thus producing a final score. After each question is answered the user input is removed from the array ? How can I carry that data in the array through through screens in Director ? Is there such a thing as a Global Array in Corona ? Do I need to use another form of data structure ?

Thanks [import]uid: 125269 topic_id: 17561 reply_id: 92794[/import]

Hey,

I believe that if your first scene is called scene1 and your second is called scene2 that provided you don’t state the array is local you should be able to access it from scene2 using scene1.arrayName :slight_smile: [import]uid: 52491 topic_id: 17561 reply_id: 92942[/import]

If you’re using Director 1.4 and you look at the code, you’ll find that yes, you can pass parameters to scenes. [import]uid: 44647 topic_id: 17561 reply_id: 95244[/import]