Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Nortos on January 20, 2008, 03:27:29 am

Title: [XP] Title Skip if no Saves
Post by: Nortos on January 20, 2008, 03:27:29 am
Title Skip if no Saves
Authors: Nortos
Version: 1
Type: Scene_Title
Key Term: Title / Save / Load / GameOver Add-on



Introduction
Ever wanted to be able to have the player skip the title scene like certain games if it's the first time they've played it or there is no saves? Well now you can!


Features




Screenshots
Screenshots not needed as there wouldn't be anything to show


Demo
Not needed as only a small script


Script
Script: ShowHide
#==============================================================================
# ** Scene_Title
# Nortos's skipable scene_title when no data
# Credits go to Nortos
# Special thanks to Fantasist, Blizzard and Zeriab for being the main teachers in my scripting
#------------------------------------------------------------------------------
#  This class performs title screen processing.
#==============================================================================

class Scene_Title
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # If battle test
    if $BTEST
      battle_test
      return
    end
    # Load database
    $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")
    # Make system object
    $game_system = Game_System.new
    # Make title graphic
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
    @sprite.visible = false
    # Make command window
    s1 = "New Game"
    s2 = "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
    @command_window.visible = false
    # Continue enabled determinant
    # Check if at least one save file exists
    # If enabled, make @continue_enabled true; if disabled, make it false
    @continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end
    # If continue is enabled, move cursor to "Continue"
    # If disabled, display "Continue" text in gray
    if @continue_enabled
      @command_window.index = 1
      $game_system.bgm_play($data_system.title_bgm)
      @command_window.visible = true
      @sprite.visible = true
    else
      command_new_game
    end
    # Play title BGM
    # Stop playing ME and BGS
    Audio.me_stop
    Audio.bgs_stop
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of command window
    @command_window.dispose
    # Dispose of title graphic
    @sprite.bitmap.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update command window
    @command_window.update
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      case @command_window.index
      when 0  # New game
        $game_system.se_play($data_system.decision_se)
        command_new_game
      when 1  # Continue
        command_continue
      when 2  # Shutdown
        command_shutdown
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Command: New Game
  #--------------------------------------------------------------------------
  def command_new_game
    # Play decision SE
    # Stop BGM
    Audio.bgm_stop
    # Reset frame count for measuring play time
    Graphics.frame_count = 0
    # Make each type of game object
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    # Set up initial party
    $game_party.setup_starting_members
    # Set up initial map position
    $game_map.setup($data_system.start_map_id)
    # Move player to initial position
    $game_player.moveto($data_system.start_x, $data_system.start_y)
    # Refresh player
    $game_player.refresh
    # Run automatic change for BGM and BGS set with map
    $game_map.autoplay
    # Update map (run parallel process event)
    $game_map.update
    # Switch to map screen
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # * Command: Continue
  #--------------------------------------------------------------------------
  def command_continue
    # If continue is disabled
    unless @continue_enabled
      # 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 load screen
    $scene = Scene_Load.new
  end
  #--------------------------------------------------------------------------
  # * Command: Shutdown
  #--------------------------------------------------------------------------
  def command_shutdown
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Fade out BGM, BGS, and ME
    Audio.bgm_fade(800)
    Audio.bgs_fade(800)
    Audio.me_fade(800)
    # Shutdown
    $scene = nil
  end
  #--------------------------------------------------------------------------
  # * Battle Test
  #--------------------------------------------------------------------------
  def battle_test
    # Load database (for battle test)
    $data_actors        = load_data("Data/BT_Actors.rxdata")
    $data_classes       = load_data("Data/BT_Classes.rxdata")
    $data_skills        = load_data("Data/BT_Skills.rxdata")
    $data_items         = load_data("Data/BT_Items.rxdata")
    $data_weapons       = load_data("Data/BT_Weapons.rxdata")
    $data_armors        = load_data("Data/BT_Armors.rxdata")
    $data_enemies       = load_data("Data/BT_Enemies.rxdata")
    $data_troops        = load_data("Data/BT_Troops.rxdata")
    $data_states        = load_data("Data/BT_States.rxdata")
    $data_animations    = load_data("Data/BT_Animations.rxdata")
    $data_tilesets      = load_data("Data/BT_Tilesets.rxdata")
    $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
    $data_system        = load_data("Data/BT_System.rxdata")
    # Reset frame count for measuring play time
    Graphics.frame_count = 0
    # Make each game object
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    # Set up party for battle test
    $game_party.setup_battle_test_members
    # Set troop ID, can escape flag, and battleback
    $game_temp.battle_troop_id = $data_system.test_troop_id
    $game_temp.battle_can_escape = true
    $game_map.battleback_name = $data_system.battleback_name
    # Play battle start SE
    $game_system.se_play($data_system.battle_start_se)
    # Play battle BGM
    $game_system.bgm_play($game_system.battle_bgm)
    # Switch to battle screen
    $scene = Scene_Battle.new
  end
end



Instructions

Just place above main and other custom scripts and below Scene_Debug


Compatibility Issues

None that I can think of


Credits and Thanks




Author's Notes

Title: Re: Title Skip if no Saves
Post by: Blizzard on January 20, 2008, 08:23:30 am
If you made that aliased, you could make it have like less than 50 lines of code. ^_^
BTW, here's a nice hint:

If you removed the methods that you didn't edit from your script and tell the users to put this extra below Scene_Title, you will both lose in number of coded lines and get in compatibility and easies deinstallation of your script.
Title: Re: Title Skip if no Saves
Post by: Fantasist on January 20, 2008, 01:14:30 pm
Unless I'm wrong, the only method that's modified is main, right? If that's the case, to alias the script, you need to perform the check for savefiles yourself, right? Like this:

alias main_title_skip main
def main
  cont_enabled = (0..3).any? {|i| FileTest.exist?('Save' + (i+1).to_s)}
  cont_enabled ? main_title_skip : command_new_game
end
Title: Re: Title Skip if no Saves
Post by: Blizzard on January 20, 2008, 01:48:07 pm
You just got owned, Nortos. >.< I WILL TAKE REVENGE FOR YOU!

alias main_title_skip main
def main
  ((0..3).any? {|i| FileTest.exist?("Save{i+1}".rxdata)}) ? main_title_skip : command_new_game
end
Title: Re: Title Skip if no Saves
Post by: Fantasist on January 20, 2008, 01:56:25 pm
Aw, that was not my intension, lol! But yeah, I just missed the extension :P

I was talking more to myself and half asking you, because I always wondered how to alias something in main and I answered myself.
Title: Re: Title Skip if no Saves
Post by: Nortos on January 20, 2008, 06:46:24 pm
:P I hadn't thought it out...was a 2minute script before went to bed lol
Title: Re: Title Skip if no Saves
Post by: Blizzard on January 20, 2008, 07:07:45 pm
Maybe you didn't get owned by FTS after all... Anyway, I shortened it by 1 line and fixed a bug, so I win. *adds 1 energy to self*

...

*or not...* ._.
Title: Re: Title Skip if no Saves
Post by: Nortos on January 20, 2008, 07:11:00 pm
:P I would but it wasn't much effort would rather save it for when 1.9 abs released or ur quest scene. But anyway ty for fix :)
Title: Re: [XP] Title Skip if no Saves
Post by: FlyingHamsta on August 14, 2008, 03:50:08 am
Sorry for bumping a very old post, but I recently found the title skip script by Blizzard and would like to use it, but I don't understand where I'm supposed to place this 'alias' code.

Anyone care to enlighten me?  =]
Title: Re: [XP] Title Skip if no Saves
Post by: Fantasist on August 14, 2008, 05:53:21 am
You mean this:

alias main_title_skip main
def main
  ((0..3).any? {|i| FileTest.exist?("Save{i+1}".rxdata)}) ? main_title_skip : command_new_game
end


You need to add two more lines at the top and bottom, so your code looks like this:

class Scene_Title
alias main_title_skip main
def main
  ((0..3).any? {|i| FileTest.exist?("Save{i+1}".rxdata)}) ? main_title_skip : command_new_game
end
end


Now paste this just above main.
Title: Re: [XP] Title Skip if no Saves
Post by: Blizzard on August 14, 2008, 06:37:15 am
FTS, Tons? >:3

It should be like this, BTW:


class Scene_Title
  alias main_title_skip main
  def main
    $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
    ((0..3).any? {|i| FileTest.exist?("Save#{i+1}.rxdata")}) ? main_title_skip : command_new_game
  end
end

Title: Re: [XP] Title Skip if no Saves
Post by: Fantasist on August 14, 2008, 06:44:04 am
There's that addon in tons? o.o
I checked 6.54b, and it's not there! Or do you mean adding this in Tons? If so, yeah!
Title: Re: [XP] Title Skip if no Saves
Post by: Blizzard on August 14, 2008, 06:59:26 am
No, it's not. I meant to add it, but I noticed something I didn't like when I tested it so meh. Here's the full script anyway:

#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Title Skip if by Blizzard
# Version: 1.0b
# Type: Game Alteration
# Date 20.1.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Instructions:
#
#   This add-on will automatically skip the title.
#   
#   
# Configuration:
#
#   Set up the following constants to configure this add-on:
#   
#   SAVE_NUMBER    - number of save files
#   SAVE_NAME      - name of save files
#   SAVE_EXTENSION - extension of save files
#   SKIP_MODE      - 0: always (just skip)
#                    1: if no save files (starts a new game)
#                    2: if any save files (opens load screen)
#
#
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#==============================================================================
# module BlizzCFG
#==============================================================================

module BlizzCFG
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  SAVE_NUMBER = 4
  SAVE_NAME = 'Save'
  SAVE_EXTENSION = 'rxdata'
  SKIP_MODE = 1

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
end

#==============================================================================
# Scene_Title
#==============================================================================

class Scene_Title
 
  alias main_title_skip_later main
  def main
    $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
    exists = ((1..BlizzCFG::SAVE_NUMBER).any? {|i| FileTest.exist?(
          "#{BlizzCFG::SAVE_NAME}#{i}.#{BlizzCFG::SAVE_EXTENSION}")})
    case BlizzCFG::SKIP_MODE
    when 0 then exists ? command_continue : command_new_game
    when 1 then exists ? main_title_skip_later : command_new_game
    when 2 then exists ? command_continue : main_title_skip_later
    else
      main_title_skip_later
    end
  end

end
Title: Re: [XP] Title Skip if no Saves
Post by: Fantasist on August 14, 2008, 08:37:09 am
Something you don't like?
Title: Re: [XP] Title Skip if no Saves
Post by: Blizzard on August 14, 2008, 09:39:57 am
"confirm" sound is being played. I know how this can be avoided (loading a dummy Data_System bofore and the real one after), but I'm not sure if this will work with other systems without problems.
Title: Re: [XP] Title Skip if no Saves
Post by: Fantasist on August 14, 2008, 11:00:42 am
Oh... $data_system isn't read-only, is it? I'll try this out.
Title: Re: [XP] Title Skip if no Saves
Post by: FlyingHamsta on August 14, 2008, 06:28:20 pm
Ah, thank you very much for the full script.  =]

EDIT: Just tested it, works well.  A suggestion:

-Is it possible to differentiate between loading the game and 'returning to title'?  For example, right now if I start the game up, it skips the title as intended, but if I use the Return to Title option and there's still no save file, it skips the title once more and starts a new game again.
Title: Re: [XP] Title Skip if no Saves
Post by: Fantasist on August 15, 2008, 07:06:24 am
@Bliz: The game crashes if there's a savefile because command_continue checks for @continue_enabled and returns if it'sfalse/nil.

@FlyingHamsta: If I understand right, you need this feature only when starting the game and everywhere else, you'd like to use the normal title screen? Okay, so here's how I'd make it work.

- In the script, change the line "class Scene_Title" to "class Scene_Begin < Scene_Title".
- Now just below, you'll see "alias main_title_skip_later main". Erase that line.
- Now find this:

exists = ((1..BlizzCFG::SAVE_NUMBER).any? {|i| FileTest.exist?(
          "#{BlizzCFG::SAVE_NAME}#{i}.#{BlizzCFG::SAVE_EXTENSION}")})


and add this line just below:

@continue_enabled = exists


- Next, wherever you see "main_title_skip_later", replace that with "super". You can use Ctrl+H for replacing.
- Now, go to the 'Main' script slot and change "Scene_Title" to "Scene_Begin". I tried this out and it works fine.
Title: Re: [XP] Title Skip if no Saves
Post by: FlyingHamsta on September 04, 2008, 02:53:46 am
Just implemented it myself and replying to let you know it works great.  Thanks again!