1 Save Slot / AutoLoad Saved Game
#1
1 Save Slot / AutoLoad Saved Game
by Kyonides-Arkanthos



Purpose of The Script

This is a simple script that allows you to save your game data in a single data file (not the 4 as always) and if you want to load it, it'll do it automatically.

Technically, it's just a modification of both scripts, Scene_Title and Scene_Menu.

SCRIPT

Code:
# 1 Save Slot / AutoLoad Saved Game
#  by Kyonides-Arkanthos
#  v 1.0 - 03.10.2010
class Scene_Title
  def command_continue
    return $game_system.se_play($data_system.buzzer_se) if !@continue_enabled
    $game_system.se_play($data_system.decision_se) # Play decision SE
    load_saved_file
  end
  
  def load_saved_file
    $game_system.se_play($data_system.load_se) # Play load SE
    file = File.open('Save1.rxdata', 'rb') # Read save data
    read_save_data(file)
    file.close
    # Restore BGM and BGS
    $game_system.bgm_play($game_system.playing_bgm)
    $game_system.bgs_play($game_system.playing_bgs)
    $game_map.update # Update map (run parallel process event)
    $scene = Scene_Map.new # Switch to map screen
  end
  
  def read_save_data(file)
    characters = Marshal.load(file) # Read character data for drawing save file
    Graphics.frame_count = Marshal.load(file) # Read frame count (4 play time)
    # Read each type of game object
    $game_temp          = Game_Temp.new # Maker new Game_Temp class (bug fix)
    $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
      $game_map.setup($game_map.map_id) # Load map
      $game_player.center($game_player.x, $game_player.y)
    end
    $game_party.refresh # Refresh party members
  end
end

class Scene_Menu
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If command other than save or end game, and party members = 0
      if $game_party.actors.size == 0 and @command_window.index < 4
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Branch by command window cursor position
      case @command_window.index
      when 0  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Item.new
      when 1  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Make status window active
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4  # save
        # If saving is forbidden
        if $game_system.save_disabled
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to save screen
        $scene = Scene_Save.new
      when 5  # end game
        # Play decision SE
        save_game_data
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end
      return
    end
  end
  
  def save_game_data
    $game_system.se_play($data_system.save_se) # Play save SE
    file = File.open('Save1.rxdata', 'wb') # Write save data
    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)
  end
  
  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[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)
    # 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)
  end
end

NOTES

Since it's so simple, I don't think I can be proud of it, but from time to time someone ends up asking for a script like this one, like Valdred did a couple of months ago. That's why I considered necessary to post it here so many more people can take a look at it and see if it fits their needs.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
#2
You are right to submit it. I've been asked for one a few months ago, and somebody made such a script for RMVX as well.
And being simple doesn't mean being useless. :)
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Name Game Switch & Variable XP kyonides 0 1,077 06-27-2023, 09:17 PM
Last Post: kyonides
   Drago Save Layout LiTTleDRAgo 2 6,737 10-09-2017, 07:08 AM
Last Post: LiTTleDRAgo
   Multi-Slot Equipment Script Guillaume777 3 13,307 05-26-2013, 07:28 PM
Last Post: Pia Carrot
Photo  Map Tileset Changer during the game Narzew 1 6,387 05-06-2013, 09:18 PM
Last Post: Narzew
   DerVVulfman's Game Data Sneak DerVVulfman 1 7,428 04-03-2013, 08:42 PM
Last Post: Taylor
   Mr.Mo ABS Game Log Window JayRay 0 5,348 10-30-2012, 06:54 AM
Last Post: JayRay
   Limit Breaker - breaks game limits Narzew 1 6,365 10-09-2012, 10:35 AM
Last Post: MetalRenard
   MrMo DVV Add-On #11: Amanda's Slot Extension DerVVulfman 0 5,415 05-19-2010, 04:56 AM
Last Post: DerVVulfman
   Multi-Slot Store Patch DerVVulfman 9 16,689 12-15-2009, 10:24 PM
Last Post: explocion200
   Card Game Data Structure Trickster 5 11,373 12-09-2009, 06:38 PM
Last Post: Trickster



Users browsing this thread: 1 Guest(s)