Temp Save v1.1

View previous topic View next topic Go down

Temp Save v1.1

Post  Fantasist on Sat Feb 09, 2008 9:44 pm

Temp Save
Version: 1.1
Type: Save Feature



Introduction

With this script, the 'Save' option in the menu will do a quick save and take you to the title screen, which will have a 'Quick Save' option instead of 'Continue'. On loading a quick save, the quick save file is deleted after loading the game.


Features

  • Imitates the quick save feature found in many games
  • Saving from menu will quick save instead of opening the save scene (and leaves the actual saving only for save points in the game)
  • The 'Continue' option in the game becomes 'Quick Load' (or any text you want) when you're taken to the title screen after a quick save



Screenshots

Pointless :p


Demo

On request Smile (respect my laziness and just try it out on a new project Wink)



Script

Place it anywhere above 'Main' and below 'Scene_Title'.

Script:
Spoiler:
Code:
#==============================================================================
# Temp Save v1.1
#  - by Fantasist
#==============================================================================

#==============================================================================
# Config Begin
#==============================================================================

Quick_Save_Path = 'Data/' # Path of the quick save file
Quick_Save_Name = 'tmp' # Name of the quick save file
Quick_Save_Ext = '' # extension of the quick save file

Quick_Load_Text = 'Quick Load' # text to be displayed instead of 'Continue' when there's a quick save

Change_Save_Count = true # Whether quick saving increases save count

# For preventing the player to copy the file by using Alt+Tab, I recommmend the following
# names. It only prevents the player from figuring out what the extra file is, during gameplay.
#
#  Quick_Save_Path = 'Data/'
#  Quick_Save_Name = 'tmp'
#  Quick_Save_Ext = '' # extension of the quick save file
#==============================================================================
# Config End
#==============================================================================

Quick_Save = Quick_Save_Path + Quick_Save_Name + '.' + Quick_Save_Ext

#==============================================================================
# ** Scene_Menu
#==============================================================================

class Scene_Menu
 
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if $game_party.actors.size == 0 && @command_window.index < 4
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @command_window.index
      when 0  # item
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new
      when 1  # skill
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # equipment
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # status
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4  # save
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        quick_save
      when 5  # end game
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
      end
    end
  end
 
  def quick_save
    file = File.open(Quick_Save, 'wb')
    characters = []
    $game_party.actors.each {|actor|
      characters.push([actor.character_name, actor.character_hue])
    }
    Marshal.dump(characters, file)
    Marshal.dump(Graphics.frame_count, file)
    $game_system.save_count += 1 if Change_Save_Count
    $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)
    file.close
    $scene = Scene_Title.new
  end
 
end

#==============================================================================
# ** Scene_Title
#==============================================================================

class Scene_Title
 
  def main
    if $BTEST
      battle_test
      return
    end
    $data_actors        = load_data('Data/Actors.rxdata')
    $data_classes      = load_data('Data/Classes.rxdata')
    $data_skills        = load_data('Data/Skills.rxdata')
    $data_items        = load_data('Data/Items.rxdata')
    $data_weapons      = load_data('Data/Weapons.rxdata')
    $data_armors        = load_data('Data/Armors.rxdata')
    $data_enemies      = load_data('Data/Enemies.rxdata')
    $data_troops        = load_data('Data/Troops.rxdata')
    $data_states        = load_data('Data/States.rxdata')
    $data_animations    = load_data('Data/Animations.rxdata')
    $data_tilesets      = load_data('Data/Tilesets.rxdata')
    $data_common_events = load_data('Data/CommonEvents.rxdata')
    $data_system        = load_data('Data/System.rxdata')
    $game_system = Game_System.new
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
    s1 = 'New Game'
    s2 = FileTest.exist?(Quick_Save) ? Quick_Load_Text : 'Continue'
    s3 = 'Shutdown'
    @command_window = Window_Command.new(192, [s1, s2, s3])
    @command_window.back_opacity = 160
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 288
    @continue_enabled = (0..3).any? {|i| FileTest.exist?("Save#{i+1}.rxdata")} ||
      FileTest.exist?(Quick_Save)
    if @continue_enabled
      @command_window.index = 1
    else
      @command_window.disable_item(1)
    end
    $game_system.bgm_play($data_system.title_bgm)
    Audio.me_stop
    Audio.bgs_stop
    Graphics.transition
    loop {
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    }
    Graphics.freeze
    @command_window.dispose
    @sprite.bitmap.dispose
    @sprite.dispose
  end
 
  alias fant_quick_save_cmd_cont command_continue
  def command_continue
    if FileTest.exist?(Quick_Save)
      quick_load
    else
      fant_quick_save_cmd_cont
    end
  end
 
  def quick_load
    $game_temp = Game_Temp.new unless $game_temp
    $game_system.se_play($data_system.load_se)
    file = File.open(Quick_Save, 'rb')
    read_quick_load(file)
    file.close
    File.delete(Quick_Save)
    $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 read_quick_load(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



Instructions

In script header. Not many instructions, just set three parameters and you're done.


Compatibility

Incompatible with CMSes and anything that modifies 'main' in Scene_Title.


Credits and Thanks

Fantasist for making this.
Special thanks to dmoose for requesting.


Author's Notes

This 'feature' can be implemented even with other CMSes or stuff, post the CMS you're using and I'll make it compatible. If you have any problems, post here. Enjoy Smile


Last edited by Fantasist on Wed Feb 20, 2008 8:17 pm; edited 1 time in total

Fantasist
Admin

Posts : 53
Join date : 2008-01-13

View user profile http://quantumcore.forumotion.com

Back to top Go down

Re: Temp Save v1.1

Post  Nortos on Mon Feb 11, 2008 12:14 pm

looks nice good job Smile

Nortos

Posts : 32
Join date : 2008-01-22

View user profile

Back to top Go down

Re: Temp Save v1.1

Post  dmoose on Tue Feb 12, 2008 11:26 am

Thanks for helping me with this and making one, this is great but..

I get an error on line 136 every time i try to start the game, says: unintialized constant scene: Scene_Title::Game

dmoose

Posts : 3
Join date : 2008-02-12

View user profile

Back to top Go down

Re: Temp Save v1.1

Post  Fantasist on Tue Feb 19, 2008 2:43 am

Sorry I didn't respond, just got my comp working again (check date and time). I'll look into it ASAP Smile

EDIT: Okay, replace this line:

Code:
@continue_enabled = (0..3).any? {|i| FileTest.exist?(Game.make_savename(i))} ||

with this:
Code:
@continue_enabled = (0..3).any? {|i| FileTest.exist?("Save#{i+1}.rxdata")} ||

That should work. I made the script from my project, and that Game thing is a convenience and compatibility measure for my game, I often make the mistake of not removing it when submitting a script, hehe Smile

Fantasist
Admin

Posts : 53
Join date : 2008-01-13

View user profile http://quantumcore.forumotion.com

Back to top Go down

Re: Temp Save v1.1

Post  dmooseno on Wed Feb 20, 2008 5:42 am

Wow, this is really cool. It works just like how I imagined it except I found some very minor bugs lol.

1. The Continue option doesn't change, I have to pick New Game to load the quick save which is kinda weird to do.
2. The End Game option in the main menu no longer works. Dunno why it's like that.

Sorry that I used a list, I thought it would be easier to read. Again, minor bugs, if you can find the time to fix them cool, if not then its okay, I'll still use the script.

Anyway, I just have to say that this is really cool and thank you for picking up my request.

Thanks,
dmoose

dmooseno
Guest


Back to top Go down

Re: Temp Save v1.1

Post  dmoose on Wed Feb 20, 2008 6:01 am

EDIT: Actually I would like to add that there is a major bug, I can't get to the status menu. It seems that the status is quick save and the save is actually end game. I have a custom skill system that slightly alters the menu options so maybe thats the problem, can you take a look at it?

dmoose

Posts : 3
Join date : 2008-02-12

View user profile

Back to top Go down

Re: Temp Save v1.1

Post  Fantasist on Wed Feb 20, 2008 7:16 pm

1. The Continue option doesn't change, I have to pick New Game to load the quick save which is kinda weird to do.
2. The End Game option in the main menu no longer works. Dunno why it's like that.

1. Could you explain in more detail? Like, when does the glitch show up? when:
- There's no temp save or no save game saved
- There's temp save saved and no saved games saved
- There are both temp save and savefiles

And what happens when you chose Continue?

2. No longer works, meaning nothing happens? No sound either? To the best of my knowledge, that shouldn't happen...

EDIT: Actually I would like to add that there is a major bug, I can't get to the status menu. It seems that the status is quick save and the save is actually end game. I have a custom skill system that slightly alters the menu options so maybe thats the problem, can you take a look at it?

It's pretty easy to fix. If you can send me the CMS you're using, I'll mod it (with proper comments and instructions in case you want to undo the changes).


Last edited by Fantasist on Wed Feb 20, 2008 8:04 pm; edited 3 times in total

Fantasist
Admin

Posts : 53
Join date : 2008-01-13

View user profile http://quantumcore.forumotion.com

Back to top Go down

Re: Temp Save v1.1

Post  Fantasist on Wed Feb 20, 2008 8:22 pm

Updated to v1.1

Bug fix: When you quick-save and close the game, open it again and quick load, the game crashes because there's no instance of Game Temp active. I've fixed that with this line:
Code:
$game_temp = Game_Temp.new unless $game_temp

That makes a new Game_Temp object unless one already exists.

Another thing is, you can now set what text should replace 'Continue' in the title screen when there's a quick-save.

@dmoose: This update is unrelated to your bugs, and the glitch you mentioned in the title screen doesn't happen to me...

Fantasist
Admin

Posts : 53
Join date : 2008-01-13

View user profile http://quantumcore.forumotion.com

Back to top Go down

Re: Temp Save v1.1

Post  dmoose on Fri Feb 22, 2008 9:54 pm

CMS

Thats the script I use, its a skill system that i found. It alters the menu slightly by making a new option between Equip and Status named Orbs. So that could be why the line up in my game got all screwy when I tried to enter this save script. I would of posted it down as a spoiler code but the forum tells me that the message is too big so there's a link to it.

dmoose

Posts : 3
Join date : 2008-02-12

View user profile

Back to top Go down

Re: Temp Save v1.1

Post  Fantasist on Sat Feb 23, 2008 7:35 pm

Okay, I checked out the script and here's where you need to mod it:

1) In part 3, search for "class Scene_Menu"
2) then scroll down to "def update_command"
3) There, you'll see things like "when 0", "when 1", ...
scroll down to "when 5". This will be the code you'll see:
Code:

when 5 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new

4) Now, replace that part with this:
Code:

when 5 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
#=========This is the original code=========
# Uncomment to re-enable

=begin
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
=end

#=================================

#=========== This is the new addon===========
# Delete this to disable, no original code has been disturbed,
# these two lines have been added.
$game_system.se_play($data_system.decision_se)
quick_save
#====================================

I've just commented the old code and added the new code.

5) Now place the Obr Skills script BELOW the Temp Save script and you're done.


PS: What about the problems in the title screen? As I said, I didn't have any problem even in a new project.

Fantasist
Admin

Posts : 53
Join date : 2008-01-13

View user profile http://quantumcore.forumotion.com

Back to top Go down

Re: Temp Save v1.1

Post  dmooseno on Sun Feb 24, 2008 6:59 am

Now it's just not working. The save option is still the same. The features that the script is supposed to give is now not shown, at all.

dmooseno
Guest


Back to top Go down

Re: Temp Save v1.1

Post  dmooseno on Sun Feb 24, 2008 7:06 am

scratch that, I thought you meant the Temp Save script. I modded the orbs script and now it works. works like a charm. thanks a bunch man, this is AWESOME! thanks for having patience with me and helping to make this. Again, thank you!!

dmooseno
Guest


Back to top Go down

Re: Temp Save v1.1

Post  Nortos on Sun Feb 24, 2008 4:39 pm

FTS is awesome Razz

Nortos

Posts : 32
Join date : 2008-01-22

View user profile

Back to top Go down

Re: Temp Save v1.1

Post  Fantasist on Sun Feb 24, 2008 4:50 pm

Aw, thanks guys Very Happy

Fantasist
Admin

Posts : 53
Join date : 2008-01-13

View user profile http://quantumcore.forumotion.com

Back to top Go down

Re: Temp Save v1.1

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum