Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Forced Save?
#1
I tried to force a save using
file = File.open(filename, "wb")
write_save_data(file)
file.close
in a call script, but I keep getting a name error in the interpreter for the word filename. How exactly am I supposed to do this without using a full script. I only want it to force a save at the end of a chapter and when using certain items. So I don't really need a full script for this.
Reply }
#2
My dear Yin,

You may not need a full script for this, but allow me to present one to you just in case. Punk himself penned it.


XP - Force Save before something

I believe you merely call $scene =Scene_ForceSave2.new to bring up the save screen where you choose what slot to use.
Reply }
#3
Ok, this works, but how will I make it automatically save over the slot that is in use... To prevent cheating. So I don't want the player to choose. I mean, they can still cheat if they put their mind to it and save in a different slot before using the item then it forces the save over the slot while they can still load the other save.
Reply }
#4
Ah. So what you are doing is making it so the player starts a game with a specific save slot which he uses throughout that one game. If he decides to start over, he can use the second slot (as an example), but your savegames can only be performed in the slot you started with.

Is that the case? You start off by having the game force an initial 'save' before the story starts?
Reply }
#5
If I have to. That makes more sense. So how would I make it so that it forces an initial save?
Reply }
#6
Well, for an initial 'SAVE" at the start of the game, you should also store a variable/value like $gameslotnumber which indicates the save slot you're using. It'll be based on the index of the save slot window.

You would acquire this same $gameslotnumber when you load a game from the title screen, so this number will be in memory for any and all 'saves' you use.

I guess this makes it so saves are even easier as you only can use one slot. ;) The same one slot throughout the game.

And with this one value, you generate the filename, like...

Code:
#--------------------------------------------------------------------------
  # * Make File Name
  #     file_index : save file index (0-3)
  #--------------------------------------------------------------------------
  def make_filename(file_index)
    return "Save#{file_index + 1}.rxdata"
  end
Ripped from the default system.
Reply }
#7
OK, I got the force save when pressing new game part. I just added this
Code:
$game_temp.save_calling = true
    $scene = Scene_Save.new
to scene title. If you press cancel it takes you back to the title screen and when you choose a save spot, it takes you to the game. So that works pretty well for the most part. Now, the hard part (for me at least) is finding which file it was saved to.
on_cancel I put
Code:
if $game_system.save_count == 0
         $scene = Scene_Title.new
That's why it goes back to title screen. I don't know if that is the best way to do it.
Reply }
#8
Remember this in Scene_File's update method?
Code:
# If C button was pressed
    if Input.trigger?(Input::C)
      # Call method: on_decision (defined by the subclasses)
      on_decision(make_filename(@file_index))
      $game_temp.last_file_index = @file_index
      return
    end
Try adding a $gamesaveindex = @file_index in there, and then reference it when you make the savefile name for later use in saves:

Code:
return "Save#{$gamesaveindex + 1}.rxdata"
... or something.
Reply }
#9
Ok, I'll try this out now.
EDIT: Ok I got it working!
Reply }
#10
Way to go! :)

Well, this topic is resolved.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Map name as save file name Whisper 9 8,246 05-01-2020, 05:35 PM
Last Post: Whisper
   Weird error when using a custom save script. Steel Beast 6Beets 8 9,927 06-27-2015, 05:54 PM
Last Post: Steel Beast 6Beets
   Custom Save/Load screen Raou 2 6,864 04-01-2015, 08:18 PM
Last Post: Raou
   Script Request - Variables Specific Save File JayRay 2 4,468 04-28-2014, 05:15 AM
Last Post: JayRay
   Save Screen Screenshot Yin 2 5,503 07-05-2010, 06:31 PM
Last Post: Yin
   Help With Law's Save System Ryu-ka 0 3,407 04-06-2010, 06:37 PM
Last Post: Ryu-ka
   Need advice on best/easiest save setup rcg916 3 5,522 11-08-2009, 06:24 AM
Last Post: DerVVulfman
   How can I save a map? Charlie Fleed 3 6,044 07-08-2009, 09:55 PM
Last Post: dacloudster
   Load/save cache files DerVVulfman 0 3,417 04-03-2009, 07:39 AM
Last Post: DerVVulfman



Users browsing this thread: