Quick Save System
#1
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


ok Here is my first script:


RPGXP Quick Save System By Eccid

Ok, I'm Truly excited about this. This is My first Script EVER!!!!

Background Story:
I found a while back on polymortis a script that changes the original save
system into a temporary save system. I liked the concept but not the way
it was set up. I wanted a system for temporary saving that was set aside
from the regular saving system. So after I learned more of the basics of
RGSS I decided to take a crack at making the script better.

How it works:
With this script I have set it up to where in your menu in place of "Save"
It says "Quick Save". When you click on "Quick Save" it takes you to a
save screen (not the regular one) and when you save it takes you to
the title screen. As soon as you load the game it deletes the Quick Save
file that you loaded.

The Script:

Ok this script is Semi-complicated and will work Fine if you do EXACTLY as
I say. You will make 4 new scripts, and edit two original scripts.

Step 1

Make a new Script above Window_Shopcommand and name it Window_QuickSaveFile and insert this into it:
Code:
#==============================================================================
# ■ Window_QuickSaveFile
#==============================================================================
class Window_QuickSaveFile < Window_Base

attr_reader   :filename                
attr_reader   :selected                

def initialize(file_index, filename)
   super(0, 64 + file_index % 4 * 104, 640, 104)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = $fontface
   self.contents.font.size = $fontsize
   @file_index = file_index
   @filename = "QSave#{@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

def refresh
   self.contents.clear
   self.contents.font.color = normal_color
   name = "Quick Save #{@file_index + 1}"
   self.contents.draw_text(4, 0, 600, 32, name)
   @name_width = contents.text_size(name).width
   if @file_exist
     for i in 0...@characters.size
       bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
       cw = bitmap.rect.width / 4
       ch = bitmap.rect.height / 4
       src_rect = Rect.new(0, 0, cw, ch)
       x = 300 - @characters.size * 32 + i * 64 - cw / 2
       self.contents.blt(x, 68 - ch, bitmap, src_rect)
     end
     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.draw_text(4, 8, 600, 32, time_string, 2)
     self.contents.font.color = normal_color
     time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
     self.contents.draw_text(4, 40, 600, 32, time_string, 2)
   end
end
def selected=(selected)
   @selected = selected
   update_cursor_rect
end
def update_cursor_rect
   if @selected
     self.cursor_rect.set(0, 0, @name_width + 8, 32)
   else
     self.cursor_rect.empty
   end
end
end


Step 2:

Make a new Script above Main and name it Scene_Quick File and insert this into it:

Code:
#==============================================================================
# ■ Scene_QuickFile
#==============================================================================
class Scene_QuickFile
def initialize(help_text)
   @help_text = help_text
end
def main
   @help_window = Window_Help.new
   @help_window.set_text(@help_text)
   @savefile_windows = []
   for i in 0..3
     @savefile_windows.push(Window_QuickSaveFile.new(i, make_filename(i)))
   end
   @file_index = $game_temp.last_file_index
   @savefile_windows[@file_index].selected = true
   Graphics.transition
   loop do
     Graphics.update
     Input.update
     update
     if $scene != self
       break
     end
   end
   Graphics.freeze
   @help_window.dispose
   for i in @savefile_windows
     i.dispose
   end
end
def update
   @help_window.update
   for i in @savefile_windows
     i.update
   end
   if Input.trigger?(Input::C)
     on_decision(make_filename(@file_index))
     $game_temp.last_file_index = @file_index
     return
   end
   if Input.trigger?(Input::B)
     on_cancel
     return
   end
   if Input.repeat?(Input::DOWN)
     if Input.trigger?(Input::DOWN) or @file_index < 3
       $game_system.se_play($data_system.cursor_se)
       @savefile_windows[@file_index].selected = false
       @file_index = (@file_index + 1) % 4
       @savefile_windows[@file_index].selected = true
       return
     end
   end
   if Input.repeat?(Input::UP)
     if Input.trigger?(Input::UP) or @file_index > 0
       $game_system.se_play($data_system.cursor_se)
       @savefile_windows[@file_index].selected = false
       @file_index = (@file_index + 3) % 4
       @savefile_windows[@file_index].selected = true
       return
     end
   end
end
def make_filename(file_index)
   return "QSave#{file_index + 1}.rxdata"
end
end


Step 3:

Make another Script above Main and name it Scene_QuickSave and insert this into it:

Code:
#==============================================================================
# ■ Scene_QuickSave
#==============================================================================

class Scene_QuickSave < Scene_QuickFile
def initialize
   super("Which file do you want to save to?")
end
def on_decision(filename)
$game_system.se_play($data_system.save_se)
file = File.open(filename, "wb")
write_save_data(file)
file.close
$scene = Scene_Title.new
end
def on_cancel
   $game_system.se_play($data_system.cancel_se)
   if $game_temp.save_calling
     $game_temp.save_calling = false
     $scene = Scene_Map.new
     return
   end
   $scene = Scene_Menu.new(4)
end
def write_save_data(file)
   characters = []
   for i in 0...$game_party.actors.size
     actor = $game_party.actors[i]
     characters.push([actor.character_name, actor.character_hue])
   end
   Marshal.dump(characters, file)
   Marshal.dump(Graphics.frame_count, file)
   $game_system.save_count += 1
   $game_system.magic_number = $data_system.magic_number
   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


Step 4:

Make ANOTHER *sigh* script above Main and name it Scene_QuickLoad and insert this into it:

Code:
#==============================================================================
# ■ Scene_QuickLoad
#------------------------------------------------------------------------------
#  ロード画面の処理を行うクラスです。
#==============================================================================

class Scene_QuickLoad < Scene_QuickFile
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
   # テンポラリオブジェクトを再作成
   $game_temp = Game_Temp.new
   # タイムスタンプが最新のファイルを選択
   $game_temp.last_file_index = 0
   latest_time = Time.at(0)
   for i in 0..3
     filename = make_filename(i)
     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("Which file do you wish to load from?")
end
#--------------------------------------------------------------------------
# ● 決定時の処理
#--------------------------------------------------------------------------
def on_decision(filename)
unless FileTest.exist?(filename)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.load_se)
file = File.open(filename, "rb")
read_save_data(file)
file.close
File.delete(filename)
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
$game_map.update
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● キャンセル時の処理
#--------------------------------------------------------------------------
def on_cancel
   # キャンセル SE を演奏
   $game_system.se_play($data_system.cancel_se)
   # タイトル画面に切り替え
   $scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# ● セーブデータの読み込み
#     file : 読み込み用ファイルオブジェクト (オープン済み)
#--------------------------------------------------------------------------
def read_save_data(file)
   # セーブファイル描画用のキャラクターデータを読み込む
   characters = Marshal.load(file)
   # プレイ時間計測用のフレームカウントを読み込む
   Graphics.frame_count = Marshal.load(file)
   # 各種ゲームオブジェクトを読み込む
   $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 $game_system.magic_number != $data_system.magic_number
     # マップをリロード
     $game_map.setup($game_map.map_id)
     $game_player.center($game_player.x, $game_player.y)
   end
   # パーティメンバーをリフレッシュ
   $game_party.refresh
end
end


Almost done!

Step 5:

Got to Scene_Title and add another option to the list called Quick load. (If you don't know how to do this ask someone, it's very easy).

Then find this:

Code:
@continue_enabled = false
   for i in 0..3
     if FileTest.exist?("Save#{i+1}.rxdata")
       @continue_enabled = true
     end
   end
   # コンティニューが有効な場合、カーソルをコンティニューに合わせる
   # 無効な場合、コンティニューの文字をグレー表示にする
   if @continue_enabled
     @command_window.index = 1
   else
     @command_window.disable_item(1)
   end

and right under it add this:

Code:
#What this does is set it up so that if there is no quick save
   #file then you can't use the quick save option
       for i in 0..3
     if FileTest.exist?("QSave#{i+1}.rxdata")
       @quickcontinue_enabled = true
     end
   end
   if @quickcontinue_enabled
     @command_window.index = 2 #Which ever number your "Quick Save" option is.
   else
     @command_window.disable_item(2) #Same ^
   end


Okay then find def update and add this in its correct place:

Code:
when 2 #Which ever number your "Quick Save" option is.
           unless @quickcontinue_enabled
     $game_system.se_play($data_system.buzzer_se)
     return
   end
   $game_system.se_play($data_system.decision_se)
   $scene = Scene_QuickLoad.new


Getting closer!!

Step 6:

Ok last part. Go to whatever script you are using for a menu and find where it says
"Save" and change it to "Quick Save".

Then

Go to def update_command and find where it says:

Code:
when 4  # Number may be different if you've edited your menu.
       # セーブ禁止の場合
       if $game_system.save_disabled
         # ブザー SE を演奏
         $game_system.se_play($data_system.buzzer_se)
         return
       end
       # 決定 SE を演奏
       $game_system.se_play($data_system.decision_se)
       # セーブ画面に切り替え
       $scene = Scene_Save.new


and change where it says

$scene = Scene_Save.new

to

$scene = Scene_QuickSave.new


And that is it!!!
Try my demo and give me some feedback!
Enjoy!!!
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Caldaron's Time System Caldaron 0 3,119 11-05-2006, 01:00 PM
Last Post: Caldaron
  Lives System Constance 0 2,581 08-10-2006, 01:00 PM
Last Post: Constance
  Level Up system Jimmie 0 2,647 07-24-2006, 01:00 PM
Last Post: Jimmie
  Quick Defend Raice 0 2,466 05-23-2006, 01:00 PM
Last Post: Raice
  Equipment Scrolling System Legacy 0 2,496 05-12-2006, 01:00 PM
Last Post: Legacy
  Inn & Savepoint System SephirothSpawn 0 2,497 03-08-2006, 01:00 PM
Last Post: SephirothSpawn
  Save menu edit Kairose 0 2,647 01-23-2006, 01:00 PM
Last Post: Kairose
  New Battle System V1.5 (Added Side View) Guedez 0 2,815 01-12-2006, 01:00 PM
Last Post: Guedez
  Slipknot Advance Message System Sheol 0 2,676 01-02-2006, 01:00 PM
Last Post: Sheol
  Hiding Save Option Necrol The Mage 0 2,448 12-22-2005, 01:00 PM
Last Post: Necrol The Mage



Users browsing this thread: 1 Guest(s)