How to have a global variable that keeps its value over multiple save files?

Status
Not open for further replies.

SkulleD42

Veteran
Veteran
Joined
Aug 15, 2015
Messages
76
Reaction score
7
First Language
Spanish
Primarily Uses
RMVXA
I know this question like this has been made a couple times but I still don't get it. I want to make a special building you can only enter when you complete certain objectives, but you can only complete one per save file, so you have to have at least 3 save files to get access to the building. There would be 3 variables, each for it achievement, and when you have completed those three in each save file, the building would be open for you. How can I make something this? Also sorry if this wasn't the right place to post this, I wasn't sure if this was it.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
32,560
Reaction score
8,159
First Language
German
Primarily Uses
RMMV
it's called persistent variables, and it needs a script.

there have been several scripts made for this, but a lot of the old script sites are down.
one such script should still be available on himeworks.com however.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,203
Reaction score
14,679
First Language
English
Primarily Uses
RMMV

Moving to RGSS3 (VX Ace) Script Request



You're probably looking for something with 'global' or 'persistent' in the title.
 

coyotecraft

Veteran
Veteran
Joined
Mar 13, 2012
Messages
163
Reaction score
104
First Language
English
Primarily Uses
A variable or a switch? Either way you could have the event run a script which reads the data of save files.

File.open("Save01.rvdata2")do |file| Marshal.load(file) saved_var1 = Marshal.load(file)[:variables][1] p saved_var1 end

What this does is print the value of the game variable 001 from Save01.rvdata2 in the debug console. But you could also use it as a condition to flip a switch.
if saved_var1 > 0 $game_switches[1] = true end

With 3 switches ON (meaning true), the door opens.
The trick is going through all existing save files. It's been awhile since I've played with Ace so I'm not sure what the most effective way to loop through the number of save files is.
 

SkulleD42

Veteran
Veteran
Joined
Aug 15, 2015
Messages
76
Reaction score
7
First Language
Spanish
Primarily Uses
RMVXA
Thank you everyone for your responses! Unfortunately the scripts Hime has are for RPG Maker MV, but after doing some research, I found a script by Fomar0153 for VX Ace that does what I want perfectly. Problem solved!
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,395
Reaction score
5,546
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

FirestormNeos wrote on Neikoku's profile.
the cat in your profile picture is adorable
Are the default-size "chibi" sprites really a bad thing for a project? I'm not planning to sell my game anyway but I was wondering if they were as hated as some videos seem to claim...
Only 9 things left on the to-do list before my game's next big update. Minus the soul-crushing playtesting session, of course! So close...
Retired from RPG Maker.
Anyone else who initially created a character to be a villain only to end up liking them so much that you made them a hero? :)

Forum statistics

Threads
111,428
Messages
1,061,047
Members
144,788
Latest member
fmoviesfco9
Top