Start a new game/Reset conditions and values to initial values

  • #1, by smac96Monday, 20. June 2016, 13:55 4 years ago
    Hi,

    I would like to give the players the chance to begin a new game after they finished it.

    Is there any quick way to reset all conditions and values to their initial values all in once?

    Thank you in advance!

    Newbie

    97 Posts


  • #2, by afrlmeMonday, 20. June 2016, 14:26 4 years ago
    I wish we had a better search option on here as this question has been asked loads of times before.

    The general idea is to create an autosave the first time you launch a new game, then you can query if the autosave exists, if it does then load that & if it doesn't then create it. You have to be on a regular scene not a menu scene type for autosave to work.

    There are a couple of other methods available, but none of them are what you would call easy. They are also very time consuming.

    Imperator

    6804 Posts

  • #3, by smac96Monday, 20. June 2016, 15:01 4 years ago
    Thank you AFRLme!

    PS: I need to improve my "search-skills" wink

    Newbie

    97 Posts

  • #4, by afrlmeMonday, 20. June 2016, 15:19 4 years ago
    it's hard searching for anything on here as the search options are very limited & the returned results are always hit & miss. Also it doesn't help that a lot of people often use misleading thread topics, such as: "need help" or "I have a question" or some nonsense along those lines.

    Imperator

    6804 Posts

  • #5, by sebastianMonday, 20. June 2016, 18:17 4 years ago
    Featurerequest for 4.3: "reset everything to default" grin
    ..... .

    Another option to set everything to default : the "new game" Option is only available when starting the game in the main menu. When opening the menu from other places like ingame, its quite not there. Cons: to start a new game you have to quit and start the game again.

    Thread Captain

    2334 Posts

  • #6, by smac96Monday, 20. June 2016, 18:28 4 years ago
    Another question for AFRLme: when I create the first time an autosave, why the next time it doesn't overwrite it directly? Should I delete it first?

    Newbie

    97 Posts

  • #7, by sebastianMonday, 20. June 2016, 18:30 4 years ago
    .. It should overwrite it when it has the same ID...

    Thread Captain

    2334 Posts

  • #8, by afrlmeMonday, 20. June 2016, 18:53 4 years ago
    Aye @ Sebastian.204: I think I will ask if Simon can implement a function that allows us to call it to reset all data back to the default xml data in the vis file. It would certainly save a lot of time. Although apparently you can technically already do that by using the replaceGame() Lua function & linking it to the current ved. It should reload the default settings, I've not gotten round to testing how it works yet, so I'm not sure if it reloads the game from the beginning or if it will stay on the current scene. If it reloads then it might be worth creating 2 veds. One for menu & one for the game. However you could also use Lua to write to the config ini file or another file to tell the game not to play any intro videos on game launch & immediately show the menu if a certain thing is returned from the file you wrote to or if the file exists, you could have it delete it at end session or whatever. There's options.

    @ smac96: you only need to create the autosave file one time. There's no point in overwriting it as it's only being used to store the default xml data that is stored in the vis file you exported. For quicksaving or autosaving you should use a different autosave slot entirely.

    As for overwriting save files & autosave files, that's done automatically whenever you specify a save slot or autosave slot #number & a save exists in said slot already. If you want to prevent overwriting then you need to setup some if queries & an interface with a bit of text & 2 buttons (one for yes & no) so that the player can decide if they actually want to overwrite the save file in the selected slot.

    Imperator

    6804 Posts

  • #9, by smac96Monday, 20. June 2016, 23:48 4 years ago
    Now it works: it overwrites the previous one. No clue why it didn't work at first.

    Do you guys also have a little "freeze" on the game when an autosave is being executed? Also on high-end computers I have this issue.

    Newbie

    97 Posts

  • #10, by afrlmeTuesday, 21. June 2016, 00:02 4 years ago
    Yeah, it's because it's writing data, so I think it sort of pauses whatever is happening, though that's probably not what it's actually doing. I do know that it's pretty much writing / encoding all the available data (entire game) into a save file. Usually only takes a second or so.

    I still don't understand why you want it to overwrite the data, if you are talking about the autosave file slot you are using for new game, then you only need to write it the first ever time someone launches a new game.

    Quick note: technically while you are in the development phase, you really shouldn't be using save files anyway as they become invalid whenever you make any significant changes to your project. Why? Because it's likely that old save files that were created before any changes contain incorrect or missing data due to them containing data written to them from a prior version.

    Imperator

    6804 Posts

  • #11, by smac96Tuesday, 21. June 2016, 11:23 4 years ago
    You're right! I was off topic: the overwrite/freeze issue was related to the "normal" autosave function during the gameplay and not related to the "start a new game" feature.

    The "freeze issue" is too bad, because I wanted that an automatic autosave is executed every time a scene is loaded. But with this issue the game is unplayable roll

    Newbie

    97 Posts

Write post