じ☆ve冰风 发表于 2026-8-1 12:52:36

Change Switches/Self Switches/Variables to Global Save Data

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:

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

Auto update global data when players save their game

Global data is shared among all loaded game/new game

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

Able to set the name of the save file

How to Use:

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

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:

Spoiler                Code:       
#==============================================================================# ■ Meow Face Global Data Manager#------------------------------------------------------------------------------# Change Self Switches / Switches / Variables into Global#==============================================================================# How to Use:# Paste this below Material and above All your Custom Scripts# 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








本贴来自国际rpgmaker官方论坛作者:MeowFace处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/change-switches-self-switches-variables-to-global-save-data.54165/
页: [1]
查看完整版本: Change Switches/Self Switches/Variables to Global Save Data