return to scene ?

  • #1, by magiclightWednesday, 22. August 2018, 14:49 6 years ago
    Lets say I can enter a scene from different places and I would like to return back to the same scene as I came from, is there anyway to do that ?

    Newbie

    13 Posts


  • #2, by afrlmeWednesday, 22. August 2018, 14:59 6 years ago
    You mean the previous scene you were on, or the current scene that you are already on?

    Imperator

    7285 Posts

  • #3, by magiclightThursday, 23. August 2018, 11:07 6 years ago
    The previous scene, say I make some kind of settings scene the user can goto with a key press or something, after finished there I want to return to the scene where the user was before that.

    Newbie

    13 Posts

  • #4, by afrlmeThursday, 23. August 2018, 11:22 6 years ago
    If the playable character was on the previous scene then you can use the "change to scene of character" action part - alternatively, you could store the current scene into a Lua variable before changing to the menu scene, then use that variable to go back to the previous scene.

    For example...

    execute a script >
    prev_scene = game.CurrentScene
    show scene/menu "menu"

    Now to go back to the previous scene when done you can use the execute a script action part & just inverse the script you wrote above, like so...
    game.CurrentScene = prev_scene

    It should take you back to the scene you stored in the prev_scene Lua variable you created.

    Imperator

    7285 Posts