Saving object variables/dats

(First off thanks so much for those who helped me with the objects variable and ui making questions i had. It really helped alot)

Tho i have a question that i noticed something about.

Is it possible to save specific object variables/data on a storage? As in, for example, if i will use multiple maps, i can make it so if you have a character with certain abilities they gained last map, the can keep it between maps or in a more specific example, a equip/inventory menu where you can give said equipment or abilities to certain objects. This is also for more obvious reasons like saving progress.

Or maybe, instead of storages having specific object’s variables, i can make it so storages GIVE variables to certain objects (like for example i make storage named “mc” and when you enter a new map, an “mc” object that is placed on the map will receive the data or variables that where saved in the “mc” storage)

Sorry if i always ask weird questions, im bad at wording stuff😓

If you have object named Player
Player have variable called mc
You can make Global structure variable called Save
And now if you make child variable named Player in Save structure variable it would be called as

Now you can go with setting object variable Player.Variable(mc) set to GlobalVariable(Save.Playermc)
You can even have structures inside structures
But idea here is that
You save to storage only GlobalVariable(Save)
And now all its child variables will also be saved

And trick here is that just as you can set global variable to object variable you can set object variable to global variable
So there goes your saving loading per object variable

And as a tip i would ditch object variables and just go with global
Instead of saving for Player.Variable(HP)
And now you need to create all these as global variables
I would simply have only

And then

1 Like

Thing is, there will be multiple playable characters (strategy rpg), hence why i wanna do the saving. I imagine it would be better using external events right?

No matter how many characters you gonna have for each character you will need to have object variable and global variable to save them so why both?
Like you will need to set global to object on load and object to global before save

So you would be doing double work
And having object variable gives you no benefit other than it being object variable

I think you could save also object variable but then you still will need to do it for reach map individually
So again what’s the point if you can just go with global?

I say do not listen to me try it yourself in some test project and you will understand what is better much faster than from any words i gonna type in there

And about external layouts idk if that will work
By logic it should
I personally never used them
But still you will need to save individual per map variables so again more sense to go with global i say

1 Like

I see. So from what i understand:

Global variables mean the only thing i have to do is make the object take the global variables?

I would say use is more accurate word

For example if you want to make health bar for your player

You would go with


And it would work exactly the same as if you were using object variavbles
Difference is you would not need to set global to object vars and vice-versa
But just deal with global vars

Same if player is in collision with sword
Change GlobalVariable(Data.PlayerHP) subtract 10

Player in level up
Change GlobalVariable(Data.PlayerMaxHP) add 100

And now you only save GlobalVariable(Data)
And you are set

1 Like