Quit_game via script?

  • #1, by LieMurderProfitMonday, 13. April 2015, 11:27 9 years ago
    I have a single scene with a single object that acts as a left click button, the left click action executes a script.

    In that script I have one line of code: Quit_game()

    I expect that when I click on the button the game will exit to desktop, but it does nothing. What am I doing wrong? Sorry if this is a newb question.

    Newbie

    5 Posts


  • #2, by afrlmeMonday, 13. April 2015, 11:40 9 years ago
    Why would it quit game if you type quit_game()?

    To quit the game via Lua script, you need to use the os functions.
    os.exit()
    

    ... why don't you just add the quit action part found under miscellaneous in the action part list? There's no need to script quit or anything else; unless you prefer scripting / programming over visual design / development.

    Imperator

    7278 Posts

  • #3, by LieMurderProfitTuesday, 14. April 2015, 09:56 9 years ago
    I was under the illusion that I could call actionparts from a script, was trying something I thought was simple. thanks for the reply.

    Newbie

    5 Posts

  • #4, by afrlmeTuesday, 14. April 2015, 12:39 9 years ago
    Not really, no. You can access the data structure fields & tables via Lua script. All of them can be read in one way or another & the large majority of them can be manipulated, but it's not the same thing as using action parts.

    There are loads of pre-made functions by the VS devs & myself & others that can be used to quickly do certain things, such as start or stop an action, animation etc, or update scene brightness, volume levels & much more. Check the Lua script section of the wiki.

    Imperator

    7278 Posts