Change Switches/Self Switches/Variables to Global Save Data

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
179
First Language
Meowish
Primarily Uses
Made for a request here.

This script changes the default game Switches/Self Switches/Variables into global save at the developer's choice.

Allowing them to be shared across the game saved files/new game.

Features:

[1] Able to change default Switches/Variables/Self Switches into global shared data

[2] Auto update global data when players save their game

[3] Global data is shared among all loaded game/new game

[4] Able to choose which set of data to be changed into global save data

[5] Able to set the name of the save file

How to Use:

[1] Paste this below Material and above all your custom scripts in the script editor.

[2] Use this script call to force save the global data only.

force_global_saveCompatibility:

This script overwrites the save/load method of the default engine.

It might conflicts with custom scripts that overwrite the save/load method.

Try place this script above all your custom scripts to avoid problems.

Note that Save files made before installing this script will not be usable after the installation.

Any changes made to the script after installation will require a new set of save files after that too.

Terms of Use:

Free for both commercial and non-commercial

Script:

Code:
#==============================================================================# ■ Meow Face Global Data Manager#------------------------------------------------------------------------------# Change Self Switches / Switches / Variables into Global#==============================================================================# How to Use:# [1] Paste this below Material and above All your Custom Scripts# [2] Use this script call to force save global file only#     force_global_save#==============================================================================module MeowDataManager #Do Not Remove!!#==============================================================================# Settings Area#==============================================================================  FILENAME = "Save00.rvdata2"     #File Name for Global Save  GLOBAL_SWITCH = true              #Use Global Switch? (true/false)  GLOBAL_VARIABLE = true           #Use Global Variable? (true/false)  GLOBAL_SELF_SWITCH = false      #Use Global Self Switch? (true/false)#==============================================================================# End of Settings Area# Edit anything past this line at your own risk!#==============================================================================endmodule DataManager  def self.make_save_contents #overwrite    contents = {}    contents[:system]        = $game_system    contents[:timer]         = $game_timer    contents[:message]       = $game_message    contents[:switches]      = $game_switches if !MeowDataManager::GLOBAL_SWITCH    contents[:variables]     = $game_variables if !MeowDataManager::GLOBAL_VARIABLE    contents[:self_switches] = $game_self_switches if !MeowDataManager::GLOBAL_SELF_SWITCH    contents[:actors]        = $game_actors    contents[:party]         = $game_party    contents[:troop]         = $game_troop    contents[:map]           = $game_map    contents[:player]        = $game_player    contents  end  def self.extract_save_contents(contents) #overwrite    $game_system        = contents[:system]    $game_timer         = contents[:timer]    $game_message       = contents[:message]    $game_switches      = contents[:switches] if !MeowDataManager::GLOBAL_SWITCH    $game_variables     = contents[:variables] if !MeowDataManager::GLOBAL_VARIABLE    $game_self_switches = contents[:self_switches] if !MeowDataManager::GLOBAL_SELF_SWITCH    $game_actors        = contents[:actors]    $game_party         = contents[:party]    $game_troop         = contents[:troop]    $game_map           = contents[:map]    $game_player        = contents[:player]  end  def self.make_global_contents #new    contents = {}    contents[:switches]      = $game_switches if MeowDataManager::GLOBAL_SWITCH    contents[:variables]     = $game_variables if MeowDataManager::GLOBAL_VARIABLE    contents[:self_switches] = $game_self_switches if MeowDataManager::GLOBAL_SELF_SWITCH    contents  end  def self.extract_global_contents(contents) #new    $game_switches      = contents[:switches] if MeowDataManager::GLOBAL_SWITCH    $game_variables     = contents[:variables] if MeowDataManager::GLOBAL_VARIABLE    $game_self_switches = contents[:self_switches] if MeowDataManager::GLOBAL_SELF_SWITCH  end  def self.save_game_without_rescue(index) #overwrite    File.open(make_filename(index), "wb") do |file|      $game_system.on_before_save      Marshal.dump(make_save_header, file)      Marshal.dump(make_save_contents, file)      @last_savefile_index = index    end    self.global_save    return true  end  def self.load_game_without_rescue(index) #overwrite    File.open(make_filename(index), "rb") do |file|      Marshal.load(file)      extract_save_contents(Marshal.load(file))      reload_map_if_updated      @last_savefile_index = index    end    self.global_load    return true  end  def self.global_save #new    File.open(MeowDataManager::FILENAME, "wb") do |file|      Marshal.dump(make_global_contents, file)    end    return true  end  def self.global_load #new    File.open(MeowDataManager::FILENAME, "rb") do |file|      extract_global_contents(Marshal.load(file))      reload_map_if_updated    end    return true  end  def self.setup_new_game #overwrite    create_game_objects    $game_party.setup_starting_members    $game_map.setup($data_system.start_map_id)    if File.exist?(MeowDataManager::FILENAME)      self.global_load    end    $game_player.moveto($data_system.start_x, $data_system.start_y)    $game_player.refresh    Graphics.frame_count = 0  endendclass Game_Interpreter  def force_global_save #new    DataManager.global_save  endend
 

MeowFace

Meow
Veteran
Joined
Feb 22, 2015
Messages
1,034
Reaction score
179
First Language
Meowish
Primarily Uses
Due to V3 to V4 migration, the codes in the top post is being messed up.


Here's the alternative version of the code until the webstaff can fix the top post.

Code:
#==============================================================================
# ■ Meow Face Global Data Manager
#------------------------------------------------------------------------------
# Change Self Switches / Switches / Variables into Global
#==============================================================================
# How to Use:
# [1] Paste this below Material and above All your Custom Scripts
# [2] Use this script call to force save global file only
#     force_global_save
#==============================================================================
module MeowDataManager #Do Not Remove!!
#==============================================================================
# Settings Area
#==============================================================================
  FILENAME = "Save00.rvdata2"     #File Name for Global Save
  GLOBAL_SWITCH = true              #Use Global Switch? (true/false)
  GLOBAL_VARIABLE = true           #Use Global Variable? (true/false)
  GLOBAL_SELF_SWITCH = true     #Use Global Self Switch? (true/false)
#==============================================================================
# End of Settings Area
# Edit anything past this line at your own risk!
#==============================================================================
end
module DataManager
  def self.make_save_contents #overwrite
    contents = {}
    contents[:system]        = $game_system
    contents[:timer]         = $game_timer
    contents[:message]       = $game_message
    contents[:switches]      = $game_switches if !MeowDataManager::GLOBAL_SWITCH
    contents[:variables]     = $game_variables if !MeowDataManager::GLOBAL_VARIABLE
    contents[:self_switches] = $game_self_switches if !MeowDataManager::GLOBAL_SELF_SWITCH
    contents[:actors]        = $game_actors
    contents[:party]         = $game_party
    contents[:troop]         = $game_troop
    contents[:map]           = $game_map
    contents[:player]        = $game_player
    contents
  end
  def self.extract_save_contents(contents) #overwrite
    $game_system        = contents[:system]
    $game_timer         = contents[:timer]
    $game_message       = contents[:message]
    $game_switches      = contents[:switches] if !MeowDataManager::GLOBAL_SWITCH
    $game_variables     = contents[:variables] if !MeowDataManager::GLOBAL_VARIABLE
    $game_self_switches = contents[:self_switches] if !MeowDataManager::GLOBAL_SELF_SWITCH
    $game_actors        = contents[:actors]
    $game_party         = contents[:party]
    $game_troop         = contents[:troop]
    $game_map           = contents[:map]
    $game_player        = contents[:player]
  end
  def self.make_global_contents #new
    contents = {}
    contents[:switches]      = $game_switches if MeowDataManager::GLOBAL_SWITCH
    contents[:variables]     = $game_variables if MeowDataManager::GLOBAL_VARIABLE
    contents[:self_switches] = $game_self_switches if MeowDataManager::GLOBAL_SELF_SWITCH
    contents
  end
  def self.extract_global_contents(contents) #new
    $game_switches      = contents[:switches] if MeowDataManager::GLOBAL_SWITCH
    $game_variables     = contents[:variables] if MeowDataManager::GLOBAL_VARIABLE
    $game_self_switches = contents[:self_switches] if MeowDataManager::GLOBAL_SELF_SWITCH
  end
  def self.save_game_without_rescue(index) #overwrite
    File.open(make_filename(index), "wb") do |file|
      $game_system.on_before_save
      Marshal.dump(make_save_header, file)
      Marshal.dump(make_save_contents, file)
      @last_savefile_index = index
    end
    self.global_save
    return true
  end
  def self.load_game_without_rescue(index) #overwrite
    File.open(make_filename(index), "rb") do |file|
      Marshal.load(file)
      extract_save_contents(Marshal.load(file))
      reload_map_if_updated
      @last_savefile_index = index
    end
    self.global_load
    return true
  end
  def self.global_save #new
    File.open(MeowDataManager::FILENAME, "wb") do |file|
      Marshal.dump(make_global_contents, file)
    end
    return true
  end
  def self.global_load #new
    File.open(MeowDataManager::FILENAME, "rb") do |file|
      extract_global_contents(Marshal.load(file))
      reload_map_if_updated
    end
    return true
  end
  def self.setup_new_game #overwrite
    create_game_objects
    $game_party.setup_starting_members
    $game_map.setup($data_system.start_map_id)
    if File.exist?(MeowDataManager::FILENAME)
      self.global_load
    end
    $game_player.moveto($data_system.start_x, $data_system.start_y)
    $game_player.refresh
    Graphics.frame_count = 0
  end
end
class Game_Interpreter
  def force_global_save #new
    DataManager.global_save
  end
end
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Either I just had one of those dreams where you think you're awake, or I have time traveled. I woke up at 6:58am this morning, heard my father leaving for work, laid back down, now its 1:16am.
So the overhaul on my project has been going great, I like this version of the project a lot more. It's more contained and less overly ambitious for what I can achieve given my constraints on time, money, and skills in advanced programming. I'm going to wait till my project is mostly finished to begin working UI polish again. I'm going to learn how to use LUNA MV to polish the project.
last time i used this site i was a different gender.. wow rlly makes u think... anyway transing ur gender is pretty cool and theres hair growing on my feet now 10/10
I should have listened to RPGMAKER Meme thread. I should have backed up my data. The Orphan of Time, my WIP, is completely gone, all those hours of work are completely gone :(
God what was my life before smartphones (I had a grandma's phone before wednesday)

Forum statistics

Threads
93,381
Messages
911,847
Members
122,883
Latest member
TEKILAO
Top