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.

Save Game Crash

Alright, I was wondering if someone could help me out with this.

I am sorry that I can not provide you with all of the scripts I am using in my game, but all I need to know is what kind of syntax is wrong here.

Alright, when I save my game, it puts the save into a saves folder, then I can go to the title screen, and load the game from that save. Now, when I exit the game entirely and go to load the save, I get an error and the game crashes.

Now, is there something that isn't getting saved correctly? Or what is going on. I would love it if someone could help me with this because my game can't go on with it doing this.
 
Do you have a custom save or menu script? Did you edit any scripts before you loaded your save file? The problem should be one of the two. If you can't post them all, you might want to at least list and provide links of all the scripts you're using.
 
Meh, I am using custom saves script. here it is.

#==============================================================================
    # ** Scene_Save
    #------------------------------------------------------------------------------
    #  This class performs save screen processing.
    #==============================================================================
   
    class Scene_Save
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
        $game_temp = Game_Temp.new
        $game_temp.last_file_index = 0
        latest_time = Time.at(0)
        for i in 0..LegACy::SAVE_COUNT
          filename = 'Saves/Save#{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
      end
      #--------------------------------------------------------------------------
      # * Main Processing
      #--------------------------------------------------------------------------
      def main
        @help_window = Window_Help.new
        @help_window.set_text('Which file would you like to save to?')
        @file_window = Window_File.new
        @file_window.y = 64
        @file_window.height = 416
        @file_window.width = 320
        @file_window.active = true
        @status_window = Window_FileStat.new(@file_window)
        @status_window.x = 320
        @status_window.y = 64
        @status_window.height = 416
        Graphics.transition
        loop do
          Graphics.update
          Input.update
          update
          if $scene != self
            break
          end
        end
        Graphics.freeze
        @help_window.dispose
        @file_window.dispose
        @status_window.dispose
      end
      #--------------------------------------------------------------------------
      # * Frame Update
      #--------------------------------------------------------------------------
      def update
        @help_window.update
        @file_window.update
        @status_window.update
        # If C button was pressed
        if Input.trigger?(Input::C)
          # Play save SE
          $game_system.se_play($data_system.save_se)
          # Write save data
          file = File.open(filename, 'wb')
          write_save_data(file)
          file.close
          # If called from event
          if $game_temp.save_calling
            # Clear save call flag
            $game_temp.save_calling = false
            # Switch to map screen
            $scene = Scene_Map.new
            return
          end
          # Switch to menu screen
          $scene = Scene_Menu.new(4)
          return
        end
        # If B button was pressed
        if Input.trigger?(Input::B)
          # Play cancel SE
          $game_system.se_play($data_system.cancel_se)
          # If called from event
          if $game_temp.save_calling
            # Clear save call flag
            $game_temp.save_calling = false
            # Switch to map screen
            $scene = Scene_Map.new
            return
          end
          # Switch to menu screen
          $scene = Scene_Menu.new(4)
        end
      end
      #--------------------------------------------------------------------------
      # * Write Save Data
      #    file : write file object (opened)
      #--------------------------------------------------------------------------
      def write_save_data(file)
        # Make character data for drawing save file
        characters = []
        for i in 0...$game_party.actors.size
          actor = $game_party.actors
          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)
        # Increase save count by 1
        $game_system.save_count += 1
        # 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)     
  alias kts_write_save_data write_save_data
    def write_save_data(file)
      kts_write_save_data(file)
      Marshal.dump($kts, file)
  end
      end
      #--------------------------------------------------------------------------
      # * return the selected file's name
      #--------------------------------------------------------------------------
      def filename
        return 'Saves/Save#{@file_window.index + 1}.rxdata'
      end
    end
 
Ahh ok give me a sec I'm using it too, but I don't get any errors, I did when I tried to remove the "Save" option and have another outside script to open and close the Save feature. how heavily have you modified his script?
Oh and are you using the Alternate version of it?
 
Found your problem

Code:
  alias kts_write_save_data write_save_data
    def write_save_data(file)
      kts_write_save_data(file)
      Marshal.dump($kts, file)
  end[]/code][/spoiler]

You don't have Kylock's Time System in for the save correctly.

If i'm thinking correct you just need it like this

[spoiler][code]...
        # 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)
        Marshal.dump($kts, file)
      end
...

I'm not fully positive on this since I use Near Fantastica Advanced Time System. But try that and let us know how it works.[/code]
 

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