save variable and array ?

Hi


I can understand that a temporary variable
example


var test = [x, y, w];



do not be saved.
But what about of another important variables and arrays.


example:


test = [x, y, w]; // need to be save


What are your tips, you have tips ?, because I am already quite advanced, but I completely forgot to consider this big problem.
I hope is not too late , and need to start again all my codes.


I have about 30 or 40 variable need to save and some complicate arrays.


Thank you for your advice and tips.
This script by theLEECH does what you need: just use $game_variables instead of temporary ones, follow the instructions in-script and it's done 🙂
This script by theLEECH does what you need: just use $game_variables instead of temporary ones, follow the instructions in-script and it's done 🙂



is for rpg maker vx ace , sorry forget to tell.


i need one, for rpg maker MV 🙂
You can use Game Variables to save whatever you need. Game Variables are backed up to each save file. 

Code:
// Create Array
var tmpArr = ['test', true, 145];

// Save Array to Game Variables
$gameVariables.setValue(5, tmpArr);
// ['test', true, 145]

$gameVariables.value(5)[0] = 'blah';
// ['blah', true, 145]
You can use Game Variables to save whatever you need. Game Variables are backed up to each save file. 



// Create Array
var tmpArr = ['test', true, 145];

// Save Array to Game Variables
$gameVariables.setValue(5, tmpArr);
// ['test', true, 145]

$gameVariables.value(5)[0] = 'blah';
// ['blah', true, 145]



I have thought there, but in last resort, because my personal plugin have more than 1000 line, and it will be very difficult to seeking significant all variables and arrays.


these possible to found way to detect the variables created in this manner.


// declared like this.

var Test=40; // not need to save or store in save file
var other= ['blabla']; // not need to save or store in save file

//but declared like this

Test=40; // Need to be saved
other= ['blabla'] // Need to be saved.




I do not understand why the variables declared without the (var) scope  are not automatically saved in the game.
My mistake, sorry.
@Jonforum You can also store variables in an object which is dumped to a save file ($gameSystem, $gameScreen, $gameTimer, $gameSwitches, $gameVariables, $gameSelfSwitches, $gameActors, $gameParty, $gameMap, or $gamePlayer).


$gameMap._myVariable = 'blah';


The example above will be dumped to the save file and will be available whenever the save file is loaded.
@Jonforum You can also store variables in an object which is dumped to a save file ($gameSystem, $gameScreen, $gameTimer, $gameSwitches, $gameVariables, $gameSelfSwitches, $gameActors, $gameParty, $gameMap, or $gamePlayer).



$gameMap._myVariable = 'blah';


The example above will be dumped to the save file and will be available whenever the save file is loaded.



Interesting, thank you for this idea, I'll dig

Original thread: https://forums.rpgmakerweb.com/threads/save-variable-and-array.69611/