How to make persistent memory (even when the game is closed)?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PugMasterPug

I am making a game in which there are items, and in order to make it simpler to develop I made a plugin for creating items, in which you give it a name, description, and image, and then assign it an ID, which you can pass to different objects in the world as a reference to an object with that name, description, and image (I have an script so I can have things like var item = preload("res://").new(image, title, description))

My current approach is basically creating a dictionary containing the IDs as keys for the actual item reference, the problem of course is that I want it to be permanent even when you close the editor or game. How can I do that? (Hopefully I don’t need to save the items as files for later access).

Thanks in advance.

:bust_in_silhouette: Reply From: kidscancode

When you close the game, it leaves the computer’s memory. If you need data to persist after quitting the game, you must save the data to a file, then read that data when the game is next run.

See Saving games — Godot Engine (latest) documentation in English for information.

1 Like