DE EN FR ES IT CZ

Create AutoSave in Lua

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 12 years ago
    How do I perform this action using Lua?

    Execute Autosave #1
  2. New to Visionaire Studio?

    Create point and click adventures without coding. The free version covers up to 25 scenes per project. For more scenes or to earn money with your game, you need a license.

    See the Indie Bundle Try it for free
  3. · 12 years ago
    You can't. There's currently no Lua functions that I know of relating to save / load game.

    Why do you want to use Lua for this? If you are wanting to create an automated autosave system then sure you can use Lua script to a degree for checking when it should save the game, but you will still need to create a called by other action which contains an execute autosave action part.

    How I sorted out my autosave system was to create a loop in Lua script using the mainLoop event handler, then inside the loop function I listen out for two things...

    1. scene change & 2. scene is not a menu. I update a variable with new scene if it doesn't equal the last scene & if it's not a menu then I call the called by other action containing the autosave actions.

    -- * variables * --
    local ps -- empty variable(s)
    
    -- * function used to check if game should autosave (saves on new scene [playable]) * --
    function autosaveSystem()
     if game.CurrentScene:getName() ~= ps then
      ps = game.CurrentScene:getName() -- update scene name
      if not game.CurrentScene:getBool(VSceneIsMenu) and not game.CurrentScene:isEmpty() then 
       startAction("Actions[autosave_system]")
      end
     end
    end
    
    registerEventHandler("mainLoop", "autosaveSystem") -- creates a loop function which loops autosaveSystem() function
    
  4. · 12 years ago
    I have a global key handler which watches for the Back Key (Android), so i wanted to create a save point before going to the menu.
    I'll create an action and call that then, thanks.

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?