Saving custom variables

Hello all, a random question; 


how does one go about saving custom or better yet global variables?
put your custom variable value into a global variable and it should safe alongside with the rest of the game data.


global variables ($game_variables) keep there values automaticly.


OR iam just getting you wrong.


Edit: Just saw that this is MV, and no post delete button in sight.... maybe its still accurate?
what custom/global variables are you talking about?  Give a better explanation of what you're trying to do, as there are several ways, and if people just guess as what you want, you'll end up with the wrong thing.


What is the variable for, how do you have it designed, how do you want to be able to access it?  Should it be accessed only from the current saved game, or from all of them?
@Shaz 


well the thing is, i made a plugin that heavily relies on global variables just for simplicity but then it got really complicated, anyway after completing it i realized that the data just doesn't get saved when i save the game in test mode.


@Bex


 well the plugin uses global variables but they still don't get saved.
But what do you mean by global variables?  Are they global just to the current game?  Or to ALL games?


If you've just made them global so they can be accessed from anywhere, but still belong to the current game only (not a really good design method), change them to make them a part of $gameSystem or $gamePlayer or $gameParty - whatever seems the most logical based on their purpose.  That way, they'll automatically be saved.


Otherwise you can create a class and put them all into that, so they're not global anymore, and modify the save/load functions to include your new class.
@Shaz


ok i'll try the latter. thnx 


;_;  how tho? 


I just realized that it may not be as simple as I had thought to edit the save load function, is there a simple way to do this? Or if possible could it get an example? 

Original thread: https://forums.rpgmakerweb.com/threads/saving-custom-variables.67763/