Is there something like a node ID which is specific to that node and will be the same no matter how often I execute the game? That would be super useful for saving and loading games.

  • wispy_jsp@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    10 months ago

    Yep! That would be an example of serialization. In computer science, taking an applications representation of a data type/object and formatting it as a series of bytes for storage or transmission over a network is referred to as serialization, with deserialization being the opposite process.

    In your case, I would definitely try out the ResourceUID class as it seems like it may fit your needs. You can use it to create and id and store that with the other fields in your custom data type. It returns an int so it will be very easy to use as a key in a dict. Just be sure to call add_id after creating so ResourceUID won’t generate duplicates: https://docs.godotengine.org/en/stable/classes/class_resourceuid.html#class-resourceuid-method-add-id