zahraa 26 Report post Posted January 17, 2013 yeah,i know i'm not first one who request this script but i couldn't find what i want i found a script,it auto saves the game on file 1 but i want to save it above all of savefiles and make a new bar called it auto save. thanks Share this post Link to post Share on other sites
Leon 55 Report post Posted January 18, 2013 Give me a little while to get some affairs in order, and I'll see if I can do it. Question though, what, if any, custom scripts do you have? Especially anything that involves a 'save system'. Share this post Link to post Share on other sites
zahraa 26 Report post Posted January 18, 2013 well,i have 2 custom scripts : first one used for more savefile second one used for changing savefile path i don't think they are conflicting scripts but i can post them if you think you need them to make an auto save script. here they are (i changed them a little :D) module AppData GAME_TITLE = "Game's name" def self.make_filename(index) dir = "#{ENV['APPDATA']}\\#{GAME_TITLE}" Dir.mkdir(dir) unless File.directory?(dir) return "#{dir}\\Save#{index + 1}.rxdata" end end class Scene_File def make_filename(index) return AppData.make_filename(index) end end class Scene_Title alias check_appdata_files update def update if @checked == nil (0..3).each {|i| if FileTest.exist?(AppData.make_filename(i)) @continue_enabled = true @command_window.refresh break end } @checked = true end check_appdata_files end end class Window_SaveFile def initialize(file_index, filename) super(0, 64 + file_index % 4 * 104, 640, 104) self.contents = Bitmap.new(width - 32, height - 32) @file_index = file_index @filename = AppData.make_filename(@file_index) @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 end #--------------------- # Personal Save Files # By: Polraudio # Credits: Polraudio, RPG Advocate, Cybersam # Version: 1.0 #--------------------- =begin #---------------------------------------------------- Features: - Allows you to have up to Unlimited save files - You can have a name for your save files Instructions: Place above main Contact: If you have any questions or comments you can find me at www.rmxpunlimited.net(Best Method) Or email me polraudio@gmail.com =end class Window_SaveFile < Window_Base # ------------------- def initialize(file_index, filename, position) y = 64 + position * 104 super(0, y, 640, 104) self.contents = Bitmap.new(width - 32, height - 32) @file_index = file_index @filename = @filename = AppData.make_filename(@file_index) @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 = "File #{@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[0], @characters[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 class Scene_File SAVEFILE_MAX = 10 # ------------------- def initialize(help_text) @help_text = help_text end # ------------------- def main @help_window = Window_Help.new @help_window.set_text(@help_text) @savefile_windows = [] @cursor_displace = 0 for i in 0..3 @savefile_windows.push(Window_SaveFile.new(i, make_filename(i), i)) end @file_index = 0 @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 < SAVEFILE_MAX - 1 if @file_index == SAVEFILE_MAX - 1 $game_system.se_play($data_system.buzzer_se) return end @cursor_displace += 1 if @cursor_displace == 4 @cursor_displace = 3 for i in @savefile_windows i.dispose end @savefile_windows = [] for i in 0..3 f = i - 2 + @file_index name = make_filename(f) @savefile_windows.push(Window_SaveFile.new(f, name, i)) @savefile_windows.selected = false end end $game_system.se_play($data_system.cursor_se) @file_index = (@file_index + 1) if @file_index == SAVEFILE_MAX @file_index = SAVEFILE_MAX - 1 end for i in 0..3 @savefile_windows.selected = false end @savefile_windows[@cursor_displace].selected = true return end end if Input.repeat?(Input::UP) if Input.trigger?(Input::UP) or @file_index > 0 if @file_index == 0 $game_system.se_play($data_system.buzzer_se) return end @cursor_displace -= 1 if @cursor_displace == -1 @cursor_displace = 0 for i in @savefile_windows i.dispose end @savefile_windows = [] for i in 0..3 f = i - 1 + @file_index name = make_filename(f) @savefile_windows.push(Window_SaveFile.new(f, name, i)) @savefile_windows.selected = false end end $game_system.se_play($data_system.cursor_se) @file_index = (@file_index - 1) if @file_index == -1 @file_index = 0 end for i in 0..3 @savefile_windows.selected = false end @savefile_windows[@cursor_displace].selected = true return end end end def make_filename(index) return AppData.make_filename(index) end end class Scene_Save < Scene_File def initialize super("Which file would you like 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 if $game_temp.save_calling $game_temp.save_calling = false $scene = Scene_Map.new return end $scene = Scene_Menu.new(6) 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(6) end def write_save_data(file) characters = [] for i in 0...$game_party.actors.size actor = $game_party.actors 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 class Scene_Load < Scene_File 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 would you like to load?") 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 $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 $game_system.se_play($data_system.cancel_se) $scene = Scene_Title.new end 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 thanks Share this post Link to post Share on other sites
Leon 55 Report post Posted January 19, 2013 Can you repost them with the code tag rather than spoiler? Share this post Link to post Share on other sites
zahraa 26 Report post Posted January 21, 2013 Ok here you go: module AppData GAME_TITLE = "game title" def self.make_filename(index) dir = "#{ENV['APPDATA']}\\#{GAME_TITLE}" Dir.mkdir(dir) unless File.directory?(dir) return "#{dir}\\Save#{index + 1}.rxdata" end end class Scene_File def make_filename(index) return AppData.make_filename(index) end end class Scene_Title alias check_appdata_files update def update if @checked == nil (0..3).each {|i| if FileTest.exist?(AppData.make_filename(i)) @continue_enabled = true @command_window.refresh break end } @checked = true end check_appdata_files end end class Window_SaveFile def initialize(file_index, filename) super(0, 64 + file_index % 4 * 104, 640, 104) self.contents = Bitmap.new(width - 32, height - 32) @file_index = file_index @filename = AppData.make_filename(@file_index) @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 end #--------------------- # Personal Save Files # By: Polraudio # Credits: Polraudio, RPG Advocate, Cybersam # Version: 1.0 #--------------------- =begin #---------------------------------------------------- Features: - Allows you to have up to Unlimited save files - You can have a name for your save files Instructions: Place above main Contact: If you have any questions or comments you can find me at www.rmxpunlimited.net(Best Method) Or email me polraudio@gmail.com =end class Window_SaveFile < Window_Base # ------------------- def initialize(file_index, filename, position) y = 64 + position * 104 super(0, y, 640, 104) self.contents = Bitmap.new(width - 32, height - 32) @file_index = file_index @filename = @filename = AppData.make_filename(@file_index) @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 = "File #{@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 class Scene_File SAVEFILE_MAX = 10 # ------------------- def initialize(help_text) @help_text = help_text end # ------------------- def main @help_window = Window_Help.new @help_window.set_text(@help_text) @savefile_windows = [] @cursor_displace = 0 for i in 0..3 @savefile_windows.push(Window_SaveFile.new(i, make_filename(i), i)) end @file_index = 0 @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 < SAVEFILE_MAX - 1 if @file_index == SAVEFILE_MAX - 1 $game_system.se_play($data_system.buzzer_se) return end @cursor_displace += 1 if @cursor_displace == 4 @cursor_displace = 3 for i in @savefile_windows i.dispose end @savefile_windows = [] for i in 0..3 f = i - 2 + @file_index name = make_filename(f) @savefile_windows.push(Window_SaveFile.new(f, name, i)) @savefile_windows[i].selected = false end end $game_system.se_play($data_system.cursor_se) @file_index = (@file_index + 1) if @file_index == SAVEFILE_MAX @file_index = SAVEFILE_MAX - 1 end for i in 0..3 @savefile_windows[i].selected = false end @savefile_windows[@cursor_displace].selected = true return end end if Input.repeat?(Input::UP) if Input.trigger?(Input::UP) or @file_index > 0 if @file_index == 0 $game_system.se_play($data_system.buzzer_se) return end @cursor_displace -= 1 if @cursor_displace == -1 @cursor_displace = 0 for i in @savefile_windows i.dispose end @savefile_windows = [] for i in 0..3 f = i - 1 + @file_index name = make_filename(f) @savefile_windows.push(Window_SaveFile.new(f, name, i)) @savefile_windows[i].selected = false end end $game_system.se_play($data_system.cursor_se) @file_index = (@file_index - 1) if @file_index == -1 @file_index = 0 end for i in 0..3 @savefile_windows[i].selected = false end @savefile_windows[@cursor_displace].selected = true return end end end def make_filename(index) return AppData.make_filename(index) end end class Scene_Save < Scene_File def initialize super("Which file would you like 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 if $game_temp.save_calling $game_temp.save_calling = false $scene = Scene_Map.new return end $scene = Scene_Menu.new(6) 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(6) 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 class Scene_Load < Scene_File 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 would you like to load?") 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 $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 $game_system.se_play($data_system.cancel_se) $scene = Scene_Title.new end 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 Share this post Link to post Share on other sites
Leon 55 Report post Posted January 22, 2013 Now, my turn to post some code. :P #=============================================================================== # Liz's Autosave Script #=============================================================================== module Auto_Save def self.save filename = make_filename(0) file = File.open(filename, "wb") write_save_data(file) file.close end def self.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 def self.make_filename(file_index) return AppData.make_filename(file_index) end end class Window_SaveFile < Window_Base def refresh self.contents.clear self.contents.font.color = normal_color if @file_index == 0 name = "Autosave" self.contents.font.color = disabled_color else name = "File #{@file_index}" self.contents.font.color = normal_color end 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 end class Scene_Save < Scene_File alias lizzie_autosave_ss_ondec on_decision def on_decision(filename) if @file_index == 0 $game_system.se_play($data_system.buzzer_se) return end lizzie_autosave_ss_ondec(filename) end end It utilizes save 1, renames it Autosave, then renames the rest of them 1, 2, etc. Also, you cannot SAVE over autosave, only load it. Just place it below your two other save file scripts, and it shoudl work beautifully. ^_^ I tested it thoroughly. Share this post Link to post Share on other sites
zahraa 26 Report post Posted January 22, 2013 But i can save over it ! Share this post Link to post Share on other sites
Leon 55 Report post Posted January 22, 2013 Then you have another script that is counter-acting with it, or have a different Input script...? Because I put it in with those two scripts you are using and it does work... EDIT: Here, I changed one line of code to have it read a slightly different way. Should work now. ^_^ #=============================================================================== # Liz's Autosave Script #=============================================================================== module Auto_Save def self.save filename = make_filename(0) file = File.open(filename, "wb") write_save_data(file) file.close end def self.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 def self.make_filename(file_index) return AppData.make_filename(file_index) end end class Window_SaveFile < Window_Base def refresh self.contents.clear self.contents.font.color = normal_color if @file_index == 0 name = "Autosave" self.contents.font.color = disabled_color else name = "File #{@file_index}" self.contents.font.color = normal_color end 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 end class Scene_Save < Scene_File alias lizzie_autosave_ss_ondec on_decision def on_decision(filename) if @file_index == 0 $game_system.se_play($data_system.buzzer_se) return end lizzie_autosave_ss_ondec(filename) end end 1 Marked reacted to this Share this post Link to post Share on other sites
zahraa 26 Report post Posted January 22, 2013 (edited) Sorry,there was a small problem that i just fix it.No need to change your script because IT'S EXCELLENT ! :D Thank you sooo much Edited January 22, 2013 by zahraa Share this post Link to post Share on other sites
QuesTMajoR 4 Report post Posted May 10, 2013 What would you do in order for it to save automatically? Share this post Link to post Share on other sites