save variable and array ?

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

Tokumei No

Kojima Fan
Veteran
Joined
Jul 4, 2014
Messages
199
Reaction score
39
First Language
Italian
Primarily Uses
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 :)
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
Last edited by a moderator:

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
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]
 
Last edited by a moderator:

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
@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

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
@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
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top