save to string

Announcements, support questions, and discussion for Quest Machine.
polygonya
Posts: 11
Joined: Tue Jul 27, 2021 2:08 pm

save to string

Post by polygonya »

Hello together

Since I use a SaveSystem that names the "slots" with strings, I would like to use strings to save.

So: SaveSystem.SaveToSlot("string");

Is it possible to implement this?
I was thinking about a Dictionary<string, int> saveFileMappings = new Dictionary<string, int>();

but maybe there is a simpler method? :D

Thanks for your help
Greetings
David
User avatar
Tony Li
Posts: 20646
Joined: Thu Jul 18, 2013 1:27 pm

Re: save to string

Post by Tony Li »

You could do that, but I think it may be better to do this: How To: Include Summary Info In Saved Games and save the string in the saved game data.
polygonya
Posts: 11
Joined: Tue Jul 27, 2021 2:08 pm

Re: save to string

Post by polygonya »

Thank you for your quick reply!

Oh, that's great! I have made it so far that I can now see the game time ect. in my load game menu. but if I then make a scene change, the quest always starts from the beginning.
In the save file I then find this section: \"deletedStaticQuests\":[\"RepairYourHouse\"]}"}

does this have something to do with how I create the quest or am I doing something else wrong when loading it?
User avatar
Tony Li
Posts: 20646
Joined: Thu Jul 18, 2013 1:27 pm

Re: save to string

Post by Tony Li »

Hi,

Check your player's Quest Journal component > Save Settings. Include it in saved games, and assign a unique key for your Quest Journal that you use for the Quest Journals in all of your scenes.
polygonya
Posts: 11
Joined: Tue Jul 27, 2021 2:08 pm

Re: save to string

Post by polygonya »

Hi Tony

Hmm looks like I set it all up like this...
Could it be that the quest always starts from the beginning because I create the player when loading the scene?
(i load the player prefab when i start the game)

must the Quest Machine Prefab already be included in my loadi game menu scene? so that it loads the quest correctly?
User avatar
Tony Li
Posts: 20646
Joined: Thu Jul 18, 2013 1:27 pm

Re: save to string

Post by Tony Li »

You may need to set the Save System's Frames To Wait Before Apply Data to a high enough value that it applies save data after you've created the player. If you create the player in Start(), a value of 1 is probably high enough.
polygonya
Posts: 11
Joined: Tue Jul 27, 2021 2:08 pm

Re: save to string

Post by polygonya »

such a small number can make such a big difference!!! it worked! Thank you very much.

but..
now when i save the game and go back to the game load menu scene and load the savegame again the quest is completely gone.

But if i save the game and then quit directly and start again in the game load menu scene i can load the game and the quest.

Can you also give me a hint for this? is this because the quest manager prefab comes into the game load scene when switching scenes?
User avatar
Tony Li
Posts: 20646
Joined: Thu Jul 18, 2013 1:27 pm

Re: save to string

Post by Tony Li »

Hi,

Are you saving the game in the main menu scene?

For example, are you using an Auto Save Load component, and maybe that component is saving in the main menu scene when the quest journal is empty?
polygonya
Posts: 11
Joined: Tue Jul 27, 2021 2:08 pm

Re: save to string

Post by polygonya »

Hi

No, I do everything manually.
What's strange is that when I start the game and save it and go back to the game load menu scene and load it, everything is gone... but when I go back to the game load scene and load it again, the saved state is there again.

can I / or do I have to close the quest machine when exiting and switching to the menu load scenes? so that the user interface is also gone?
User avatar
Tony Li
Posts: 20646
Joined: Thu Jul 18, 2013 1:27 pm

Re: save to string

Post by Tony Li »

Hi,
polygonya wrote: Tue Apr 16, 2024 2:29 pmWhat's strange is that when I start the game and save it and go back to the game load menu scene and load it, everything is gone... but when I go back to the game load scene and load it again, the saved state is there again.
To debug this, tick the Save System's Debug checkbox and the JsonDataSerializer's Debug checkbox. Then reproduce the issue in the Unity editor's play mode. When the game saves or loads, the Console window will report the data that the save system is saving or loading. This may give you an idea of when/if it's using old data such as a different save slot.
polygonya wrote: Tue Apr 16, 2024 2:29 pmcan I / or do I have to close the quest machine when exiting and switching to the menu load scenes? so that the user interface is also gone?
No; Quest Machine's user interface is separate from its data. Your Quest Machine GameObject should remain active when returning to the main menu, but you can run this code to make sure the UIs are hidden:

Code: Select all

QuestMachine.defaultQuestHUD.Hide();
QuestMachine.defaultQuestJournalUI.Hide();
Post Reply