Forum rules - please read before posting.
Tech questions during the weekend? Drop in on the community Discord channel!

New Game Concept Question

Hi,

I wonder how do you handle start of a new game?
I'm thinking a situation when things changed and the first scene can't simply be loaded.

I guess there are 2 options: Reset everything or load a save created the first time first scene was loaded.

AC.SaveSystem.SaveNewGame()

This method is inside SaveSystem, the way I understand this feature is a "special" slot intended for making a save at the very beginning of the game.
But how can I load it? How can I check if it exists?

Is there a way to call the Reset from a script as one method? I can't find it.
Anyway I can use the same code that's in the script of the EndGame action.
I suppose reseting is the prefered method as it's faster?

Thanks for help.

Comments

  • See the Manual's "Save scripting" chapter for the main functions that let you load and save games. A full list of what's available can be found in the Scripting Guide.

    For example, you can check if a save exists with AC.SaveSystem.DoesSaveExist (saveID).

    Restarting the game is typically done via the Engine: End game Action, but it can also be done through script. Each saveable element (inventory, scene data, etc), is reset individually:

    KickStarter.ResetPlayer (KickStarter.settingsManager.GetDefaultPlayer (), KickStarter.settingsManager.GetDefaultPlayerID (), false, Quaternion.identity);
    KickStarter.saveSystem.ClearAllData ();
    KickStarter.levelStorage.ClearAllLevelData ();
    KickStarter.runtimeInventory.OnStart ();
    KickStarter.runtimeDocuments.OnStart ();
    KickStarter.runtimeVariables.OnStart ();
    KickStarter.playerMenus.RebuildMenus ();
    KickStarter.stateHandler.CanGlobalOnStart ();
    

    To change scene afterwards, you can then call:

    KickStarter.sceneChanger.ChangeScene (new SceneInfo (mySceneName), false, true);
    
  • I'm aware of the SaveGame() and DoesSaveExist() functions. I couldn't find information on the SaveNewGame() function. It doesn't take any ID parameter. That's why it's confusing in order to load it or check whether it exists.

    Thanks for the info. I'm gonna reset the game via the script.
    Thus I won't really need a save created to load a "new game", I'm still curious what the function does, though.

    Could you please describe the difference between the SaveGame() and SaveNewGame() functions?
    I thought maybe it's a specific ID which doesn't show in SavesLists.

  • SaveGame allows you to save into a particular slot. If that slot is already "taken", it'll be overwritten by the new save.

    SaveNewGame will avoid overwriting, and save into the first-available empty slot. If saves exist in slots 1, 2 and 4, then this will save into slot 3. The ID is worked out by itself - hence no need to supply it.

  • Thank you! :)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.