Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Game Continuation script in development
- To use this script, both project must have this script
- Overview :
- I stored switches and variables in save header.
- It because if I store it in main contents, it somehow throws an error if you
- use many and complicated script in previous project.
- Also to prevent other game save file to be loaded using this script :P
- Please do not claims as yours!
- =end
- # ============================================================================
- # Configuration
- # ============================================================================
- module Theo
- module GamePlus
- Transfer_Switches = [1,2,3,4] # Switches to be transfered
- Transfer_Variables = [1,2,3,4] # Variables to be transfered
- FileName = "SavePlus" # Name for previous saved files
- end
- end
- # ============================================================================
- # End config
- # ============================================================================
- module Theo
- module GamePlus
- @gameplus = false
- @index = nil
- def self.activate
- @gameplus = true
- end
- def self.deactivate
- @gameplus = false
- end
- def self.active
- @gameplus
- end
- def self.index=(index)
- @index = index
- end
- def self.index
- @index
- end
- # ========================================================================
- # Call save file from previous game and transfer the data.
- # Have to be called when gameplus flag is active and index is set
- # ========================================================================
- def self.load
- header = DataManager.load_header(index)
- Transfer_Switches.each do |sid|
- $game_switches[sid] = header[:switches][sid]
- end
- Transfer_Variables.each do |vid|
- $game_variables[vid] = header[:variables][vid]
- end
- end
- end
- end
- class << DataManager
- # ===========================================================================
- # If gameplus flag is return true, then change the filename
- # ===========================================================================
- alias theo_gameplus_file_exist? save_file_exists?
- def save_file_exists?
- return theo_gameplus_file_exist? unless Theo::GamePlus.active
- !Dir.glob(Theo::GamePlus::Filename + '*.rvdata2').empty?
- end
- alias theo_gameplus_make_filename make_filename
- def make_filename(index)
- return theo_gameplus_make_filename(index) unless Theo::GamePlus.active
- sprintf("#{Theo::GamePlus::FileName}%02d.rvdata2", index + 1)
- end
- alias theo_gameplus_make_header make_save_header
- def make_save_header
- header = theo_gameplus_make_header
- header[:switches] = $game_switches
- header[:variables] = $game_variables
- header
- end
- alias theo_gameplus_new_game setup_new_game
- def setup_new_game
- theo_gameplus_new_game
- # Load extra data if gameplus flag is true
- Theo::GamePlus.load if Theo::GamePlus.active
- end
- end
- # ============================================================================
- # Windows for the list of saved files from previous game.
- # ============================================================================
- class Window_GameplusList < Window_Selectable
- def initialize(y)
- super(0, y, window_width, window_height)
- refresh
- to_center
- activate
- select(0)
- end
- def to_center
- self.x = (Graphics.width - width)/2
- end
- def window_width
- return 150
- end
- def window_height
- fitting_height(visible_line_number)
- end
- def visible_line_number
- return 7
- end
- def make_item_list
- @data = []
- DataManager.savefile_max.times do |i|
- next unless FileTest.exist?(DataManager.make_filename(i))
- @data.push(i)
- end
- end
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
- def draw_item(index)
- return if @data[index].nil?
- text = sprintf("%02d: File", @data[index])
- r = item_rect_for_text(index)
- draw_text(r, text)
- end
- def item_max
- @data ? @data.size : 1
- end
- end
- class Window_TitleCommand
- alias theo_gameplus_init initialize
- def initialize
- theo_gameplus_init
- set_handler(:gameplus, method(:on_gameplus))
- end
- alias theo_gameplus_make_command make_command_list
- def make_command_list
- # Placeholder command. Adds New Game+ for game continuation
- add_command("New Game+", :gameplus)
- theo_gameplus_make_command
- end
- def on_gameplus
- SceneManager.scene.close_command_window
- SceneManager.call(Scene_GamePlus)
- end
- end
- # ============================================================================
- # This is just a placeholder scene. I don't have any idea how the layout should
- # be like. Any suggestion?
- # ============================================================================
- class Scene_GamePlus < Scene_MenuBase
- def start
- super
- # Activate flag
- Theo::GamePlus.activate
- @window = Window_GameplusList.new(0)
- @window.set_handler(:ok, method(:on_load_ok))
- end
- def on_load_ok
- Theo::GamePlus.index = @window.index
- DataManager.setup_new_game
- fadeout_all
- $game_map.autoplay
- SceneManager.goto(Scene_Map)
- end
- def terminate
- super
- # Deactivate flag
- Theo::GamePlus.deactivate
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment