Global Switches?

I am working on a game in VX Ace for the first time, when I have used XP in the past.

Need to know if there are global switches in the engine, so that I can apply switches to the entire game regardless of a save file existing. I need to do this for options on the Title Screen (custom one made on the map), so changing things like adding modifiers, cheats, and other settings like game volume. Only thing is that it would have to apply to every saved game.

I guess this also raises the question of if changing a global switch would save it somewhere else, not a save file. Because for it to apply to every save file it would need to be saved somewhere in like, the Data folder, right?

If anyone could help me out with this it would be greatly appreciated 🙂
There's no such thing.

But you can achieve that using scripts. Someone probably wrote a script like that at some point, but I don't know any.
I suppose you can do I/O proccesses from a file to achieve this, but that will obviously require a script.
I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.
Fair enough, just didn't know if it was script related or engine related so I put it in the engine one xD

That's a little sucky, maybe I'll just resort to having one save file instead.
Try this: http://rpgmaker.net/scripts/320/

I use it too.
That is very intriguing. My only beef with it is that people could load that game up and it would show as like the settings in the load screen. I'd want it to be hidden so it seems like it's part of the engine. Purely aesthetic, I know. Or writing to an .ini file (or a Ruby file, or updating a script, or something) would be REALLY nice.
Not really... This is a global save. You don't actively open it. You tell it which switches  and variables to track and when to save them. After that, you place a load command. Now your might say where can I put it?
 

I personally have an evented Title menu so I just use a parallel process with a script call: "global_load"
 After the global load I place a conditional: is the X switch on? If so then allow me this extra option.

 
Add this script to your project

# ConfigFile for VXAce by Hudell# Free for non commercial and commercial use# Contact : [email hidden]# URL: www.hudell.commodule ConfigFile    SWITCHES_TO_LOAD = []    VARIABLES_TO_LOAD = []    @fileName = './Game.ini'    GetPrivateProfileString   = Win32API.new('kernel32', 'GetPrivateProfileString'  , 'ppppip'      , 'i')    WritePrivateProfileString = Win32API.new('kernel32', 'WritePrivateProfileString', 'pppp'        , 'i')      def self.getValue(section, option_name, defaultValue)        buffer = [].pack('x256')        print section.to_s + ", " + option_name.to_s + ", " + defaultValue.to_s + "\n"        value = GetPrivateProfileString.call(section, option_name, defaultValue, buffer, buffer.size, @fileName)        return buffer[0, value]    end    def self.setValue(section, option_name, value)        WritePrivateProfileString.call(section, option_name, value.to_s, @fileName)    end    def self.save_variable(variable_index)        setValue('variable', variable_index.to_s, $game_variables[variable_index])    end    def self.load_variable(variable_index)    value = getValue('variable', variable_index.to_s, $game_variables[variable_index].to_s)        $game_variables[variable_index] = value.to_i    end    def self.save_switch(switch_index)        if $game_switches[switch_index]            value = "1"        else            value = "0"        end        setValue('switch', switch_index.to_s, value)    end    def self.load_switch(switch_index)        if $game_switches[switch_index]            value = "1"        else            value = 0        end        value = getValue('switch', switch_index.to_s, value)        if value == "1"            $game_switches[switch_index] = true        else            $game_switches[switch_index] = false        end    end    def self.auto_load_stuff    SWITCHES_TO_LOAD.each do |switch_index|      load_switch(switch_index)    end    VARIABLES_TO_LOAD.each do |variable_index|      load_variable(variable_index)    end    endendclass Game_System    alias :global_switches_on_after_load 😮n_after_load  def on_after_load    global_switches_on_after_load    ConfigFile::auto_load_stuff  end    endAnd you can use those script calls to save and load values from the Game.ini file:

Save the value of variable 20:

ConfigFile.save_variable(20)Load the value of variable 20:

ConfigFile.load_variable(20)Save the state of switch 30

ConfigFile.save_switch(30)Load the state of switch 30

Code:
ConfigFile.load_switch(30)
Wow Hudell, that's freaking awesome. One question though, I can load it through a script call, but how do I know what the value is? Like, how do I tell if the switch is off or on, or what the variable is?
The same way you do with any other switch or variable. There's no difference between them.
Ohp. I'm stupid, don't listen to me xD xD

And these will be the same no matter what save file you are using, correct? 🙂 this is pretty dang awesome if it works 🙂
Ohp. I'm stupid, don't listen to me xD xD

And these will be the same no matter what save file you are using, correct? 🙂 this is pretty dang awesome if it works 🙂
Yes, you just need to call the "load_switch" function to load the value from the Game.ini file to the switch.

I can make it load it automatically everytime you load the game, do you want me to do that?
Yeah that would be fantastic! Absolutely perfect mate! You've definitely got a area in my credits x)
I updated the script on the previous post. All you need to do is to configure which switches and which variables should be loaded automatically

just insert the number of the switch / variable here:

    SWITCHES_TO_LOAD = []    VARIABLES_TO_LOAD = []
like this:

Code:
    SWITCHES_TO_LOAD = [10, 20]    VARIABLES_TO_LOAD = [11, 21]
Wow dude you're a life saver, thanks so much 😀

This thread can be locked now 🙂
I'm not quite sure that I understand correctly about the script. Please correct if I'm wrong.

Suppose, I have set v[10] to be auto-saved. Continuing from a saved file, at any point of time in my game that v[10] is set to x, so I just quit the game without saving (basically without this script, v[10] will be original value not x). Then reload the saved file and I'll see that v[10] is still x and the variable's value will be carried on to all saved files.

Am I correct? Sorry for my bad english.
They are not auto-saved, only auto-loaded.

You need to call

ConfigFile.save_variable(10)
after changing it's value in order to save it.
They are not auto-saved, only auto-loaded.

You need to call

ConfigFile.save_variable(10)after changing it's value in order to save it.
Ok clearly understand now. Very handy script you have made. Thank you!

I'm planning to have Instance dungeon mode like World of Warcraft in my project. It is kind of the same dungeon you have already completed with more difficult and challenge, boss hunts for better gears. But I want to have some wait time after each access to the dungeon and try to find a way to keep variable across all saved files to prevent restless hunting (bosses don't drop my gears so let's reload from previous saved file).
@Hudell , your script is not working for Arrays... Is there any help you could give me?

Original thread: https://forums.rpgmakerweb.com/threads/global-switches.38336/