Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Law's Custom Save vs. SDK 2.4

Hey Guys, I'm having some problems with my title page and the problem is within the conflicting scene_title sections of the two scripts (Law's Custom Save & SDK2.4). When I start the game up, the title page freezes and will not allow you to move up or down to select another option. It does allow me to play the game after pushing enter, but that's about it.

Any help on this would be appreciated.

[pastebin]423[/pastebin]

[pastebin]424[/pastebin]
 
Well, that would probably be because the Standard Development Kit rewrites three scenes necessary for a save and load file system which are: Scene_Save, Scene_Load and Scene_File. If you don't need the Standard Development Kit, delete it. If you actually do need it, you can work towards making your other script compatible. Perhaps we can help you if you show us the error.
 
There is no error that pops up. It's simply a problem within the title screen... it freezes and doesn't allow you to choose anything other than "New Game".

And yea, I would like to use the SDK, but if it comes down to it, I'll just delete it (as it is only necessary for one script that I'm using).
 
Perhaps I'd try to edit Law's custom save for SDK.(Especially Scene_Title, for if you're using SDK, there're only a few lines to edit)


**Law's Custom Save System for SDK2(it's rough conversion, and may have error):
Code:
 

#------------------------------------------------------------------------------

#==============================================================================

#==============================================================================

#======================*Law's Custom Save System*==============================

#==================Author: The Law G14 and Night_Runner========================

#============================Version 1.5=======================================

#==============================================================================

#------------------------------------------------------------------------------

 

#==============================================================================

# ** Module_Customization

#------------------------------------------------------------------------------

#  This module contains all the customization for the script

#==============================================================================

 

module Customization

  

  #----------------------------------------------------------------------------

  # * Config Begin

  #----------------------------------------------------------------------------

  

  # Here you can change the number of save slots that will be in your game

  SLOTS = 8

  # Here you can change the name of the text in the save slots

  SLOT_NAME = "Slot"

  

  # Here you can change what icon will appear next to a filename that isn't empty

  SLOT_ICON_SELECTED = "001-Weapon01"

  # Here you can change what icon will appear next to a filename that is empty

  SLOT_ICON_UNSELECTED = "002-Weapon02"

  

  # Draw Gold

  DRAW_GOLD = true 

  # Draw Playtime

  DRAW_PLAYTIME = true 

  # Draw location

  DRAW_LOCATION = true 

  # Draw Actor's face

  DRAW_FACE = true

  # Draw Actor's name

  DRAW_NAME = true

    

  # Text inside file info window when empty

  EMPTY_SLOT_TEXT = "~EMPTY~"

  

  # Playtime Text

  PLAYTIME_TEXT = "Play Time: "

  # Gold Text

  GOLD_TEXT = "Gold: "

  # Location Text

  LOCATION_TEXT = "Location: "

  

  # Map image border color (R,G,B,Opacity)

  MAP_BORDER = Color.new(0,0,0,200)

  

  # Text for help window when saving. Ex: "Which file would you like to save to?"

  SAVE_TEXT = "Which file would you like to save to?"

  # Text for help window when loading. Ex: "Which file would you like to load?"

  LOAD_TEXT = "Which file would you like to load?"

  

  # All windows' opacity (Lowest 0 - 255 Highest) 

  # Use low opacity when having a background.

  WINDOW_OPACITY = 255 

  # Background image file name, it must be in the pictures folder. 

  # Put '' if you don't want a background.

  BACKGROUND_IMAGE = '' 

  # Opacity for background image

  BACKGROUND_IMAGE_OPACITY = 255 

    

  #----------------------------------------------------------------------------

  # * Config End

  #----------------------------------------------------------------------------

 

end

 

 

 

#==============================================================================

# ** Game_Map

#------------------------------------------------------------------------------

#  This class handles the map. It includes scrolling and passable determining

#  functions. Refer to "$game_map" for the instance of this class.

#==============================================================================

 

class Game_Map

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_reader   :name

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias law_css_setup setup

  #--------------------------------------------------------------------------

  # * Setup

  #     map_id : map ID

  #--------------------------------------------------------------------------

  def setup(*args)

    # Run the original setup

    law_css_setup(*args)

    # Load the name of the map

    @name = load_data("Data/MapInfos.rxdata")[@map_id].name

  end

end

 

 

 

#==============================================================================

# ** Spriteset_Map_Loading_Preview

#------------------------------------------------------------------------------

#  This class brings together map screen sprites, tilemaps, etc for the

#   loading screen's preview.

#==============================================================================

 

class Spriteset_Map_Preview

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  RES_WIDTH =  352  # Please insert a number divisible by 32

  RES_HEIGHT = 160   # Please insert a number divisible by 32

  TOP_CORNER_X = 201

  TOP_CORNER_Y = 120

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    center

    # Make viewports

    @viewport1 = Viewport.new(TOP_CORNER_X, TOP_CORNER_Y, RES_WIDTH, RES_HEIGHT)

    @viewport2 = Viewport.new(TOP_CORNER_X, TOP_CORNER_Y, RES_WIDTH, RES_HEIGHT)

    @viewport3 = Viewport.new(TOP_CORNER_X, TOP_CORNER_Y, RES_WIDTH, RES_HEIGHT)

    @viewport1.z = 9200

    @viewport2.z = 9200

    @viewport3.z = 95000    # Make tilemap

    @tilemap = Tilemap.new(@viewport1)

    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)

    for i in 0..6

      autotile_name = $game_map.autotile_names[i]

      @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)

    end

    @tilemap.map_data = $game_map.data

    @tilemap.priorities = $game_map.priorities

    # Make panorama plane

    @panorama = Plane.new(@viewport1)

    @panorama.z = -1000

    # Make fog plane

    @fog = Plane.new(@viewport1)

    @fog.z = 3000

    # Make character sprites

    @character_sprites = []

    for i in $game_map.events.keys.sort

      sprite = Sprite_Character.new(@viewport1, $game_map.events[i])

      @character_sprites.push(sprite)

    end

    @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))

    # Make weather

    @weather = RPG::Weather.new(@viewport1)

    # Make picture sprites

    @picture_sprites = []

    for i in 1..50

      @picture_sprites.push(Sprite_Picture.new(@viewport2,

        $game_screen.pictures[i]))

    end

    # Frame update

    update

  end

  #--------------------------------------------------------------------------

  # * Dispose

  #--------------------------------------------------------------------------

  def dispose

    # Dispose of tilemap

    @tilemap.tileset.dispose

    for i in 0..6

      @tilemap.autotiles[i].dispose

    end

    @tilemap.dispose

    # Dispose of panorama plane

    @panorama.dispose

    # Dispose of fog plane

    @fog.dispose

    # Dispose of character sprites

    for sprite in @character_sprites

      sprite.dispose

    end

    # Dispose of weather

    @weather.dispose

    # Dispose of picture sprites

    for sprite in @picture_sprites

      sprite.dispose

    end

    # Dispose of viewports

    @viewport1.dispose

    @viewport2.dispose

    @viewport3.dispose

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # If panorama is different from current one

    if @panorama_name != $game_map.panorama_name or

       @panorama_hue != $game_map.panorama_hue

      @panorama_name = $game_map.panorama_name

      @panorama_hue = $game_map.panorama_hue

      if @panorama.bitmap != nil

        @panorama.bitmap.dispose

        @panorama.bitmap = nil

      end

      if @panorama_name != ""

        @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)

      end

      Graphics.frame_reset

    end

    # If fog is different than current fog

    if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue

      @fog_name = $game_map.fog_name

      @fog_hue = $game_map.fog_hue

      if @fog.bitmap != nil

        @fog.bitmap.dispose

        @fog.bitmap = nil

      end

      if @fog_name != ""

        @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue)

      end

      Graphics.frame_reset

    end

    # Update tilemap

    @tilemap.ox = $game_map.display_x / 4

    @tilemap.oy = $game_map.display_y / 4

    @tilemap.update

    # Update panorama plane

    @panorama.ox = $game_map.display_x / 8

    @panorama.oy = $game_map.display_y / 8

    # Update fog plane

    @fog.zoom_x = $game_map.fog_zoom / 100.0

    @fog.zoom_y = $game_map.fog_zoom / 100.0

    @fog.opacity = $game_map.fog_opacity

    @fog.blend_type = $game_map.fog_blend_type

    @fog.ox = $game_map.display_x / 4 + $game_map.fog_ox

    @fog.oy = $game_map.display_y / 4 + $game_map.fog_oy

    @fog.tone = $game_map.fog_tone

    # Update character sprites

    for sprite in @character_sprites

      sprite.update

    end

    # Update weather graphic

    @weather.type = $game_screen.weather_type

    @weather.max = $game_screen.weather_max

    @weather.ox = $game_map.display_x / 4

    @weather.oy = $game_map.display_y / 4

    @weather.update

    # Update picture sprites

    for sprite in @picture_sprites

      sprite.update

    end

    # Set screen color tone and shake position

    @viewport1.tone = $game_screen.tone

    @viewport1.ox = $game_screen.shake

    # Set screen flash color

    @viewport3.color = $game_screen.flash_color

    # Update viewports

    @viewport1.update

    @viewport3.update

  end

  #--------------------------------------------------------------------------

  # * Set Map Display Position to Center of Screen

  #--------------------------------------------------------------------------

  def center

    x = $game_player.real_x

    y = $game_player.real_y

    max_x = [($game_map.width - RES_WIDTH / 32) * 128, RES_WIDTH].max

    max_y = [($game_map.height - RES_HEIGHT / 32) * 128, RES_HEIGHT].max

    center_x = (RES_WIDTH/2 - 16) * 4   # Center screen x-coordinate * 4

    center_y = (RES_HEIGHT/2 - 16) * 4   # Center screen y-coordinate * 4

    $game_map.display_x = [0, [x - center_x, max_x].min].max

    $game_map.display_y = [0, [y - center_y, max_y].min].max

    $game_map.refresh

  end

end

 

 

 

#==============================================================================

# ** Window_SaveFile

#------------------------------------------------------------------------------

#  This window displays save files on the save and load screens.

#==============================================================================

 

class Window_SaveFile < Window_Base

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_reader   :filename                 # file name

  attr_reader   :selected                 # selected

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     file_index : save file index (0-3)

  #     filename   : file name

  #--------------------------------------------------------------------------

  def initialize(file_index, filename, position)

    super(0, 64 + position * 52, 115, 52)

    self.contents = Bitmap.new(width - 32, height - 32)

    reposition(position)

    @file_index = file_index

    @filename = Customization::SLOT_NAME + "#{@file_index + 1}.rxdata"

    @time_stamp = Time.at(0)

    @file_exist = FileTest.exist?(@filename)

    if @file_exist

      file = File.open(@filename, "r")

      @time_stamp = file.mtime

      @characters = Marshal.load(file)

      @frame_count = Marshal.load(file)

      @game_system = Marshal.load(file)

      @game_switches = Marshal.load(file)

      @game_variables = Marshal.load(file)

      @total_sec = @frame_count / Graphics.frame_rate

      file.close

    end

    refresh

    @selected = false

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    if @file_exist

      # Draw file number

      self.contents.font.color = normal_color

      bitmap = RPG::Cache.icon(Customization::SLOT_ICON_SELECTED)

      @opacity = 255

    else

      self.contents.font.color = disabled_color

      bitmap = RPG::Cache.icon(Customization::SLOT_ICON_UNSELECTED)

      @opacity = 100

    end

    name = Customization::SLOT_NAME + "#{@file_index + 1}"

    self.contents.draw_text(20, -7, 600, 32, name)

    @name_width = contents.text_size(name).width

    self.contents.fill_rect(0, -2, 10, 32, Color.new(0, 0, 0, 0))

    self.contents.blt(0, -2, bitmap, Rect.new(0, 0, 24, 24), opacity)

  end

  #--------------------------------------------------------------------------

  # * Set Selected

  #     selected : new selected (true = selected, false = unselected)

  #--------------------------------------------------------------------------

  def selected=(selected)

    @selected = selected

    update_cursor_rect

  end

  #--------------------------------------------------------------------------

  # * Cursor Rectangle Update

  #--------------------------------------------------------------------------

  def update_cursor_rect

    if @selected

      self.cursor_rect.set(0, -7, @name_width + 38, 32)

    else

      self.cursor_rect.empty

    end

  end

  #--------------------------------------------------------------------------

  # * Reposition

  #--------------------------------------------------------------------------

  def reposition(index)

    if index < 0 or index > 7

      self.visible = false

    else

      self.y = 64 + 52 * index

      self.visible = true

    end

  end

end

 

 

 

#==============================================================================

# ** Window_FileInfo

#------------------------------------------------------------------------------

#  This window displays file information.

#==============================================================================

 

class Window_FileInfo < Window_Base

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias nr_dispose dispose unless $@

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(115, 64, 525, 416)

    self.contents = Bitmap.new(width - 32, height - 32)

    refresh($game_temp.last_file_index)

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh(file_index)

    self.contents.clear

    @spriteset.dispose unless @spriteset.nil?

    @spriteset = nil

    @file_index = file_index

    @filename = Customization::SLOT_NAME + "#{@file_index + 1}.rxdata"

    @file_exist = FileTest.exist?(@filename)

    save_data = Customization::SLOTS

    # If save file exists

    if @file_exist

      file = File.open(@filename, "rb")

      read_file_data(file)

      file.close

      # Draw Screenshot

      begin

        width = 352 + 4

        height = 160 + 4

        x = (self.width - 32 - width) / 2

        y = 54 - 16

        self.contents.fill_rect(x, y, width, height, Customization::MAP_BORDER)

        @spriteset = Spriteset_Map_Preview.new

      end

      # Draw Gold

      if Customization::DRAW_GOLD

        cx = contents.text_size($data_system.words.gold).width

        self.contents.font.color = normal_color

        self.contents.font.size = 25

        self.contents.draw_text(40, 0, 100, 32, $game_party.gold.to_s, 2)

        self.contents.font.color = system_color

        self.contents.draw_text(140, 0, 20, 32, $data_system.words.gold, 2)

        self.contents.draw_text(-20, 0, 80, 32, Customization::GOLD_TEXT, 2)  

      end

      # Draw actor face

      if Customization::DRAW_FACE

        for i in 0...$game_party.actors.size

          actor = $game_party.actors[i]

          draw_actor_face_graphic(actor, i*129, 250)

        end  

      end

      # Draw actor name

      if Customization::DRAW_NAME

        for i in 0...$game_party.actors.size

          self.contents.font.color = system_color

          self.contents.font.size = 25

          actor = $game_party.actors[i]

          draw_actor_name(actor, (i*130) + 25, 350)

        end 

      end

      # Draw play time

      if Customization::DRAW_PLAYTIME

        @total_sec = Graphics.frame_count / Graphics.frame_rate

        hour = @total_sec / 60 / 60

        min = @total_sec / 60 % 60

        sec = @total_sec % 60

        time_string = sprintf("%02d:%02d:%02d", hour, min, sec)

        self.contents.font.color = normal_color

        self.contents.font.size = 25

        self.contents.draw_text(380, 0, 100, 32, time_string, 2)

        self.contents.font.color = system_color

        time_string = Customization::PLAYTIME_TEXT

        self.contents.draw_text(230, 0, 150, 32, time_string, 2)

      end

      # Draw Location

      if Customization::DRAW_LOCATION

        self.contents.font.color = system_color

        self.contents.font.size = 25

        self.contents.draw_text(4, 210, 120, 32, Customization::LOCATION_TEXT)

        self.contents.font.color = normal_color

        x = (Customization::LOCATION_TEXT.length * 10) + 5

        self.contents.draw_text(x, 210, 120, 32, $game_map.name.to_s, 2)

      end

    else

      self.contents.draw_text(-20, 50, self.contents.width, self.contents.height - 200, Customization::EMPTY_SLOT_TEXT, 1)

    end

  end

  #--------------------------------------------------------------------------

  # * Draw Actor Face Graphic

  #--------------------------------------------------------------------------

  def draw_actor_face_graphic(actor, x, y)

    bitmap = RPG::Cache.picture(actor.id.to_s)

    self.contents.blt(x, y, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))

  end

  #--------------------------------------------------------------------------

  # * Read Save Data

  #     file : file object for reading (opened)

  #--------------------------------------------------------------------------

  def read_file_data(file)

    # Read character data for drawing save file

    characters = Marshal.load(file)

    # Read frame count for measuring play time

    Graphics.frame_count = Marshal.load(file)

    # Read each type of game object

    $game_system        = Marshal.load(file)

    $game_switches      = Marshal.load(file)

    $game_variables     = Marshal.load(file)

    $game_self_switches = Marshal.load(file)

    $game_screen        = Marshal.load(file)

    $game_actors        = Marshal.load(file)

    $game_party         = Marshal.load(file)

    $game_troop         = Marshal.load(file)

    $game_map           = Marshal.load(file)

    $game_player        = Marshal.load(file)

    # If magic number is different from when saving

    # (if editing was added with editor)

    if $game_system.magic_number != $data_system.magic_number

      # Load map

      $game_map.setup($game_map.map_id)

      $game_player.center($game_player.x, $game_player.y)

    end

    # Refresh party members

    $game_party.refresh

  end

  #--------------------------------------------------------------------------

  # * Dispose Window

  #--------------------------------------------------------------------------

  def dispose(*args)

    nr_dispose(*args)

    @spriteset.dispose unless @spriteset.nil?

    @spriteset = nil

  end

end

 

 

 

#==============================================================================

# ** Scene_File

#------------------------------------------------------------------------------

#  This is a superclass for the save screen and load screen.

#==============================================================================

 

class Scene_File < SDK::Scene_Base

  #--------------------------------------------------------------------------

  # * Invariables

  #--------------------------------------------------------------------------

  CENTER_X = (320 - 16) * 4   # Center screen x-coordinate * 4

  CENTER_Y = (240 - 16) * 4   # Center screen y-coordinate * 4

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     help_text : text string shown in the help window

  #--------------------------------------------------------------------------

  def initialize(help_text)

    @help_text = help_text

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    super

  end  

  #--------------------------------------------------------------------------

  # * Main Processing : Variable Initialization

  #--------------------------------------------------------------------------

  def main_variable

    super

    @cursor_displace = 0

  end

  #--------------------------------------------------------------------------

  # * Main Processing : Window Initialization

  #--------------------------------------------------------------------------

  def main_window

    super

    # Make help window

    @help_window = Window_Help.new

    @help_window.set_text(@help_text)

    @help_window.opacity = Customization::WINDOW_OPACITY

    # Make save file window

    @savefile_windows = []

    for i in 0...Customization::SLOTS

      @savefile_windows.push(Window_SaveFile.new(i, make_filename(i), i))

    end

    # Select last file to be operated

    #

    @file_index = $game_temp.last_file_index

    @savefile_windows[@file_index].selected = true

    base = [7 - @file_index, 0].min    

    @savefile_windows.each_with_index { |window, index|

      window.reposition(index + base)

    }

    for i in @savefile_windows

      i.opacity = Customization::WINDOW_OPACITY

    end

    # Make FileInfo window

    @fileinfo_window = Window_FileInfo.new

    @fileinfo_window.opacity = Customization::WINDOW_OPACITY

  end

  #--------------------------------------------------------------------------

  # * Main Processing : Spriteset Initialization

  #--------------------------------------------------------------------------

  def main_spriteset

    # Make background

    @sprite = Sprite.new

    @sprite.bitmap = RPG::Cache.picture(Customization::BACKGROUND_IMAGE)

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Update windows

    super    

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Call method: on_decision (defined by the subclasses)

      on_decision(make_filename(@file_index))

      $game_temp.last_file_index = @file_index

      @fileinfo_window.refresh(@file_index)

      center

      return

    end

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Call method: on_cancel (defined by the subclasses)

      on_cancel

      return

    end

    # If the down directional button was pressed

    if Input.repeat?(Input::DOWN)

      # If we are looking at the last item

      if @file_index >= Customization::SLOTS - 1

        # If the DOWN is triggered, reset to start

        if Input.trigger?(Input::DOWN)

          @file_index = 0

          @savefile_windows.each_with_index { |window, index|

            window.reposition(index)

            window.selected = false

          }

          @savefile_windows[0].selected = true

          $game_system.se_play($data_system.cursor_se)

          @fileinfo_window.refresh(@file_index)

          return

        else

          return

        end

      end

      # Otherwise

      $game_system.se_play($data_system.cursor_se)

      @savefile_windows[@file_index].selected = false

      @file_index += 1

      @savefile_windows[@file_index].selected = true

      @fileinfo_window.refresh(@file_index)

      # If the savefile is off the screen

      if @savefile_windows[@file_index].visible == false

        @savefile_windows.each_with_index { |window, index|

          window.reposition(index - @file_index + 7)

        }

      return

      end

    end

    # If the up directional button was pressed

        if Input.repeat?(Input::UP)

      # If we are looking at the last item

      if @file_index <= 0

        # If the DOWN is triggered, reset to start

        if Input.trigger?(Input::UP)

          @savefile_windows[@file_index].selected = false

          @file_index = Customization::SLOTS - 1

          @savefile_windows[@file_index].selected = true

          @fileinfo_window.refresh(@file_index)

          if @file_index <= 7

            return $game_system.se_play($data_system.cursor_se)

          end

          @savefile_windows.each_with_index { |window, index|

            window.reposition(index - @file_index + 7)

          }

          $game_system.se_play($data_system.cursor_se)

          return

        else

          return

        end

      end

      # Otherwise

      $game_system.se_play($data_system.cursor_se)

      @savefile_windows[@file_index].selected = false

      @file_index -= 1

      @savefile_windows[@file_index].selected = true

      @fileinfo_window.refresh(@file_index)

      # If the savefile is off the screen

      if @savefile_windows[@file_index].visible == false

        @savefile_windows.each_with_index { |window, index|

          window.reposition(index - @file_index)

        }

      return

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Make File Name

  #     file_index : save file index (0-3)

  #--------------------------------------------------------------------------

  def make_filename(file_index)

    return Customization::SLOT_NAME + "#{file_index + 1}.rxdata"

  end

  #--------------------------------------------------------------------------

  # * Set Map Display Position to Center of Screen

  #--------------------------------------------------------------------------

  def center

    max_x = ($game_map.width - 20) * 128

    max_y = ($game_map.height - 15) * 128

    x = $game_player.x

    y = $game_player.y

    $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max

    $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max

  end

end

 

 

 

#==============================================================================

# ** Scene_Save

#------------------------------------------------------------------------------

#  This class performs save screen processing.

#==============================================================================

 

class Scene_Save < Scene_File

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias law_css_scene_save_initialize initialize unless $@

  alias nr_css_scene_save_main main unless $@

  alias nr_css_scene_save_update update unless $@

  alias nr_css_scene_save_on_decision on_decision unless $@

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize(*args)

    backup_data

    law_css_scene_save_initialize(*args)

    super(Customization::SAVE_TEXT)

  end

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main(*args)

    nr_css_scene_save_main(*args)

    load_backup_data

    File.delete("backup_temp.rxdata") if File.exist?('backup_temp.rxdata')

    center

  end

  #--------------------------------------------------------------------------

  # * On Decision

  #--------------------------------------------------------------------------

  def on_decision(*args)

    load_backup_data

    nr_css_scene_save_on_decision(*args)

    $scene = Scene_Menu.new(4)

  end

  #--------------------------------------------------------------------------

  # * Backup Data

  #--------------------------------------------------------------------------

  def backup_data

    file = File.open('backup_temp.rxdata', "wb")

    # Make character data for drawing save file

    characters = []

    for i in 0...$game_party.actors.size

      actor = $game_party.actors[i]

      characters.push([actor.character_name, actor.character_hue])

    end

    # Write character data for drawing save file

    Marshal.dump(characters, file)

    # Wrire frame count for measuring play time

    Marshal.dump(Graphics.frame_count, file)

    # Save magic number

    # (A random value will be written each time saving with editor)

    $game_system.magic_number = $data_system.magic_number

    # Write each type of game object

    Marshal.dump($game_system, file)

    Marshal.dump($game_switches, file)

    Marshal.dump($game_variables, file)

    Marshal.dump($game_self_switches, file)

    Marshal.dump($game_screen, file)

    Marshal.dump($game_actors, file)

    Marshal.dump($game_party, file)

    Marshal.dump($game_troop, file)

    Marshal.dump($game_map, file)

    Marshal.dump($game_player, file)

    file.close

  end

  #--------------------------------------------------------------------------

  # * Load Backup Data

  #--------------------------------------------------------------------------

  def load_backup_data

    filename = 'backup_temp.rxdata'

    file = File.open(filename, "rb")

    # Read character data for drawing save file

    characters = Marshal.load(file)

    # Read frame count for measuring play time

    Graphics.frame_count = Marshal.load(file)

    # Read each type of game object

    $game_system        = Marshal.load(file)

    $game_switches      = Marshal.load(file)

    $game_variables     = Marshal.load(file)

    $game_self_switches = Marshal.load(file)

    $game_screen        = Marshal.load(file)

    $game_actors        = Marshal.load(file)

    $game_party         = Marshal.load(file)

    $game_troop         = Marshal.load(file)

    $game_map           = Marshal.load(file)

    $game_player        = Marshal.load(file)

    # If magic number is different from when saving

    # (if editing was added with editor)

    if $game_system.magic_number != $data_system.magic_number

      # Load map

      $game_map.setup($game_map.map_id)

      $game_player.center($game_player.x, $game_player.y)

    end

    # Refresh party members

    $game_party.refresh

    file.close

  end

  #--------------------------------------------------------------------------

  # * Load Backup Data

  #--------------------------------------------------------------------------

  def erase_game_data

    Graphics.frame_count = 0

    # Make each type of game object

    $game_temp          = Game_Temp.new

    $game_system        = Game_System.new

    $game_switches      = nil

    $game_variables     = nil

    $game_self_switches = nil

    $game_screen        = nil

    $game_actors        = nil

    $game_party         = nil

    $game_troop         = nil

    $game_map           = nil

    $game_player        = nil

  end

end

 

 

 

#==============================================================================

# ** Scene_Load

#------------------------------------------------------------------------------

#  This class performs load screen processing.

#==============================================================================

 

class Scene_Load < Scene_File

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    # Remake temporary object

    $game_temp = Game_Temp.new

    # Timestamp selects new file

    $game_temp.last_file_index = 0

    latest_time = Time.at(0)

    for i in 0...Customization::SLOTS

      filename = Customization::SLOT_NAME + "#{i + 1}.rxdata"

      if FileTest.exist?(filename)

        file = File.open(filename, "r")

        if file.mtime > latest_time

          latest_time = file.mtime

          $game_temp.last_file_index = i

        end

        file.close

      end

    end

    super(Customization::LOAD_TEXT)

  end

end

 

 

 

#==============================================================================

# ** Scene_Title

#------------------------------------------------------------------------------

#  This class performs title screen processing.

#==============================================================================

 

class Scene_Title < SDK::Scene_Base

  #--------------------------------------------------------------------------

  # * Main Test Initialization

  #--------------------------------------------------------------------------

  def main_test_continue

    # Set Continued Enabled Flag Off

    @continue_enabled = false

    # Checks For Save Files

    # Sets Continued Enable Flag On

    @continue_enabled = (Dir.glob(Customization::SLOT_NAME + '*.rxdata').size > 0)

  end

end

 

 
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top