Status
Not open for further replies.

AgentN107

Bringer of laughter
Veteran
Joined
Aug 21, 2018
Messages
33
Reaction score
3
First Language
English
Primarily Uses
RMVXA
Boy I had hard time naming this. I have not posted in the forms for awhile sorry this might not be exactlly in the right spot(also doing from my first time and it is being a pain). I have a point in my demo where one section is primarlly auto save. When the player leaves and saves again the auto save is removed. Now to my question when I open the save menue it goes to this save(which is outside my file selection for it being just outside max save files) so I have found nurmous code in the defualt and yanfly save script that looked like they would fix this but I have come up empty. I know I need to put disabling code I just don't know where.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,908
Reaction score
14,546
First Language
English
Primarily Uses
RMMV
How did you do the autosave and the removal of the autosave file? I suspect you'll need to save the "last savefile number" before creating the autosave the first time, and then reset it after the autosave is removed, but how you do that will depend on how you've done the creation and removal of autosaved.
 

AgentN107

Bringer of laughter
Veteran
Joined
Aug 21, 2018
Messages
33
Reaction score
3
First Language
English
Primarily Uses
RMVXA
So I auto save with a script that saves on player transfer and I have it delete the save when the player saves their game as usual which is in my yanfly script in def on_action_save.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,908
Reaction score
14,546
First Language
English
Primarily Uses
RMMV
I guessed that you probably had a script, but unless you tell us what it is (or post it here, if it's one you wrote yourself), we won't be able to help you much.

Moving to RGSSx Script Support

 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,986
Reaction score
665
First Language
English
Primarily Uses
RMVXA
Now to my question when I open the save menue it goes to this save(which is outside my file selection for it being just outside max save files)
This works.
storing the last file index then returning it to the DataManager.last_savefile_index
Ruby:
module DataManager
  def self.last_save(index)
    @last_savefile_index = index
  end
end

class Scene_Map
  alias auto_post_transfer post_transfer
  def post_transfer
    auto_post_transfer
    return unless AUTOSAVE_ON_MAP
    last_file = DataManager.last_savefile_index
    if Module.const_defined?(:Game_Options)
      DataManager.save_game(0) if $game_options.auto_save
    else
      DataManager.save_game(0) if $auto_save
    end
    DataManager.last_save(last_file)
  end
end

module BattleManager
  def self.battle_end(result)
    @phase = nil
    @event_proc.call(result) if @event_proc
    $game_party.on_battle_end
    $game_troop.on_battle_end
    SceneManager.exit if $BTEST
    return unless AUTOSAVE_AFTER_BATTLE
    last_file = DataManager.last_savefile_index
    if Module.const_defined?(:Game_Options)
      DataManager.save_game(0) if $game_options.auto_save
    else
      DataManager.save_game(0) if $auto_save
    end
    DataManager.last_save(last_file)
  end
end
Just change the save_game(0) to whatever number you are using for the autosave slot.
Or just take the few lines I used and put them in Vlue's autosave script.
 

AgentN107

Bringer of laughter
Veteran
Joined
Aug 21, 2018
Messages
33
Reaction score
3
First Language
English
Primarily Uses
RMVXA
Oh was not expecting to be given re-written code. That happily surprised me. Even more so that it did not need me to touch my yanfly script. There is a small problem. So when I need to load the autosave then leave the area and save normally the problem comes back. My guess is the index is not getting saved in the auto save
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,194
Reaction score
843
First Language
Hungarian
Primarily Uses
RMVXA
The last_savefile_index is automatically set to the last loaded save file after loading it, and that would be your autosave file in this case.
You can add a check to see if it is the autosave file, and if it is, set the index to the 2nd latest savefile instead (if there are any other files, that is), or just skip the line that sets the last_savefile_index variable.

In the DataManager class:
Code:
  def self.load_game_without_rescue(index)
    File.open(make_filename(index), "rb") do |file|
      Marshal.load(file)
      extract_save_contents(Marshal.load(file))
      reload_map_if_updated
      @last_savefile_index = index unless index == 0 # Edited line!
    end
    return true
  end
Replace the 0 on the edited line there with the savefile index you use for the autosave feature.
Should work, but not tested.
 

AgentN107

Bringer of laughter
Veteran
Joined
Aug 21, 2018
Messages
33
Reaction score
3
First Language
English
Primarily Uses
RMVXA
What are you using to load the autosave?
I am using the primary load method DataManger.load_game(autosave) and the post loading needed for it to work right. They are loaded from the gameover and when the game starts.
The last_savefile_index is automatically set to the last loaded save file after loading it, and that would be your autosave file in this case.
You can add a check to see if it is the autosave file, and if it is, set the index to the 2nd latest savefile instead (if there are any other files, that is), or just skip the line that sets the last_savefile_index variable.

In the DataManager class:
Code:
  def self.load_game_without_rescue(index)
    File.open(make_filename(index), "rb") do |file|
      Marshal.load(file)
      extract_save_contents(Marshal.load(file))
      reload_map_if_updated
      @last_savefile_index = index unless index == 0 # Edited line!
    end
    return true
  end
Replace the 0 on the edited line there with the savefile index you use for the autosave feature.
Should work, but not tested.
This did the trick
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,303
Reaction score
5,472
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Updated the dev logs for the game I'm working on! Check it out here
Alright, I left the modern girl in fantasy brain's hands while I get my - MODERN GIRL WHAT HAPPENED?! I blame fantasy brain for this.

WinaElemental.png
I just realized that, while I was waiting for our little Easter Game to be approved in the Completed Games Thread, the game was already listed for more than a week, without me noticing x.x

So ... very delayed happy easter to everyone I guess? : D
WIP
3t2Xc52pKS7ptwWCFMrSen.png

Forum statistics

Threads
110,560
Messages
1,054,258
Members
143,673
Latest member
hesena
Top