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,550
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,196
Reaction score
14,665
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,386
Reaction score
5,542
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 Profile Posts

here's another RPG Maker remake idea: "Plumbers Don't Wear Ties". I'll salute to whomever does this
I won't finish it today, I only will have time to work on that next Saturday, what a shame... :(
I made something for @LittenDev [as he requested]
It's been a weird while. I've been so torn down that even playing video games has been something I avoided. But I shouldn't forget two things. One, I love RPG Maker for a reason. Two, only way to eat an elephant is a bite at a time.

Forum statistics

Threads
111,385
Messages
1,060,721
Members
144,728
Latest member
Izaya_Nozomu
Top