change scene with luo script

  • #1, by petertermanhansenSaturday, 21. August 2021, 15:51 2 years ago
    hi

    I have seen here how to change scene with luo-script.
    But I dont get my character with me. In the editor I would give a position, to place my character, but with the luo game.scene command the is no object, to place the character.
    How to do that?

    regards Peter

    Newbie

    81 Posts


  • #2, by afrlmeSaturday, 21. August 2021, 17:58 2 years ago
    It would require multiple lines of code to do that with Lua script.

    1. you need to specify the scene you want to change the current scene to.
    2. you need to specify which scene the character is on.
    3. you need to specify the position you want the character to be placed at in the new scene.
    4. you need to specify the alignment for the character.

    definition script:
    function changeScene(scn, obj)
    
     game.CurrentScene = Scenes[scn]
    
     game.CurrentCharacter.Scene = Scenes[scn]
    
     game.CurrentCharacter.Position = Scenes[scn].Objects[obj].Position
    
     game.CurrentCharacter.Direction = Scenes[scn].Objects[obj].Direction
    
    end


    usage:
    changeScene("insert scene name here", "insert object name here")

    Imperator

    7278 Posts

  • #3, by petertermanhansenSaturday, 21. August 2021, 20:38 2 years ago
    Thanks - works perfect.

    Newbie

    81 Posts