Forum rules - please read before posting.

Save Game and Custom label

edited November 2017 in Engine development
[edit: sorry, it was for the Technical category]

In my game I changed some behavior of the Save / Load AC menus.
Instead of making the Save / Load menu appear on the main screen I created a black background where the player can switch from one menu to another.
But this way I can not have a screenshot when I save because it would only be a black background.
I therefore thought to do this in the following way:
In the Save Menu I unchecked Save when click on and I created an ActionList that returns to the game screen before saving the game.
In the EventManager.OnMenuElementClick script I intercept the Save click in this way:

if (_menu.title == "Save") {
  // todo: (next line) will change according to the language set?
  if (_element.GetLabel (_slot, 0) != "Salva nuovo livello") {
    GlobalVariables.SetIntegerValue (3, _slot, true);
    string scene = LocalVariables.GetStringValue (12, 0);
    int useLang = Options.GetLanguage();
    string useCulture;
    switch (useLang) {
      case 0:
        useCulture = "it-IT";
        break;
      case 1: 
        useCulture = "en-US";
        break;
      case 2: 
        useCulture = "fr-FR";
        break;
      default:
        useCulture = "en-US";
        break;
    }
    string timeSave = DateTime.Now.ToString (CultureInfo.CreateSpecificCulture(useCulture));
    string labelSave = scene + ": " + timeSave;
    GlobalVariables.SetStringValue (4, labelSave, true);
  }
  return;
}

With this code I create a custom save string as:
(Italian) Appartamento di Jack: 20/11/2017 13.22.51
or
(english) Jack's Apartment: 11/20/2017 1:22:51 PM
which I save in a global variable and that I read at the time of saving the game.

But this code works only when I overwrite an already stored file because in the ActionList Save -> Save or Load -> Overwrite Existing Save I can use a custom label as String Variable.
However, I can not define the same custom label in Save New Game.
How could I do? Maybe by modifying the AC code?

Comments

  • I have noticed that saving a new file also happens without using Save -> Save or Load -> Save new Game.
    If I click on the New Save slot and in the ActionList I use Overwrite Existing Save the file is saved as if it was a new file.
    This way my custom label can be applied in both cases.
    But a question: could problems arise?


  • Setting a custom label when writing a new game is supposed to be possible - the option is not displaying because of a bug.

    I'll fix it in the upcoming release, but you can show it by:

    1) Change the Method to Overwrite Existing Save
    2) Set the Save to override to Set Slot Index
    3) Change the Method back to Save New Game
  • edited November 2017
    Yes, I've tried it and it works. Thanks.
    However, I'm undecided to use this feature.
    To use it I should check out from code if the player clicked on the Save new game. I thought I would use

    if (_element.GetLabel (_slot, 0) == "Salva nuovo livello")

    but I should also check the language set and change the comparison string.
    It would seem though that Overwrite works even if the slot clicked is Save new game.
    I thought I would leave it so but I was wondering if random problems could occur.


  • edited November 2017
    I don't imagine so.  If the file is saved correctly in the folder the Console displays, it'll be available when loading games.
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.
Do NOT follow this link or you will be banned from the site!