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,875
Reaction score
14,524
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,875
Reaction score
14,524
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,983
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,270
Reaction score
5,448
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 Profile Posts

besides itch and occasionally here where are people doing game jams at y'all? (plz do not cross reference this with my previous status lol)
Go out all day!
★No work★
Just want to sleep when I get home Zzzzz
just went through 50 issues of Fables, only to left kind of disappointed by it, I guess I have to wait for season 2 of TWAU instead.
Untitled Project.gif

Feel free to subscribe, cuz im gonna release it first there.
https://crashykk.itch.io/crashykk-retro-tileset
and_remember_tomorrow_beside_myself.jpg

The worst part about making custom stuff is, I can't really ask any of you why a second copy of the character randomly appears only when going SW, S, or SE and changing directions. Been bugging me for the last two days. On the plus side, look at the new random map pieces I made while thinking about it.:LZSexcite:

Forum statistics

Threads
110,437
Messages
1,053,278
Members
143,504
Latest member
7MrLucky7
Top