Menu
Login
Language
DE EN FR ES IT CZ
Back

change scene with luo script

  • #1, by petertermanhansen Saturday, 21. August 2021, 15:51 4 years ago Quote
    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

    84 Posts

  • #2, by afrlme Saturday, 21. August 2021, 17:58 4 years ago Quote
    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

    7290 Posts

  • #3, by petertermanhansen Saturday, 21. August 2021, 20:38 4 years ago Quote
    Thanks - works perfect.

    Newbie

    84 Posts