Dynamic Title

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by Yato, Jun 25, 2013.

    Tags:
  1. Yato

    Yato (aka Racheal) Veteran

    Messages:
    826
    Likes Received:
    344
    Location:
    Canada

    Dynamic Title 1.1
    by Racheal




    Introduction
    This script changes the title screen based on a variable set in-game. This could be used, for example, to add a character to the title screen after you meet them.

    Features

    • Change the background, foreground, or both.
    • Pull the variable from the latest save or the highest from all the saves.
    • Use numbers corresponding to the variable for your images or set the names of the files you would like to use

    How to Use
    Insert the script anywhere in the Materials section above Main.

    Script

    Code:
    
    #==============================================================================
    # Dynamic Title
    # by: Racheal
    # Version 1.1
    # Created: 24/06/2013
    # Updated: 27/09/2013
    #==============================================================================
    # Changes the title screen based on a variable set in-game.
    #==============================================================================
    # Instructions:
    # * Insert in the Materials section
    # * Configure to your liking below
    #==============================================================================
    # Compatibility:
    # This script is for RPG Maker VX Ace
    # It is unlikely to work with anything that modifies the way the
    # title screen is drawn such as an animated title screen
    # * Overwrites: Scene_Title: create_background
    #==============================================================================
    
    #==============================================================================
    # Customization
    #==============================================================================
    module Racheal_Title
      #Set which variable controls the change in the title screen
      TITLE_VARIABLE = 5
      
      #Set which parts of the title screen are affected
      CHANGE_BACKGROUND = true
      CHANGE_FOREGROUND = true
      
      #Set whether to check the highest variable in all the save files or
      #just use the most recent save
      CHECK_ALL_SAVES = false
      
      #Set whether to use a series of numbers for the filenames (0.png, 1.png, etc)
      #or a series of names you define below
      USE_FILENAMES = true
      BACKGROUND_NAMES = ["Volcano", "Night"]
      FOREGROUND_NAMES = ["Gargoyles", ""]
    end
    #==============================================================================
    # End Customization
    #==============================================================================
    
    #==============================================================================
    # ** DataManager
    #==============================================================================
    
    module DataManager
      #--------------------------------------------------------------------------
      # * Create Save Header
      #--------------------------------------------------------------------------
      class << self; alias dynamic_title_make_save_header make_save_header; end
      def self.make_save_header
          header = dynamic_title_make_save_header
          header[:title] = $game_variables[Racheal_Title::TITLE_VARIABLE]
          header
      end 
    end
    
    #==============================================================================
    # ** Scene_Title
    #==============================================================================
    
    class Scene_Title < Scene_Base
      #--------------------------------------------------------------------------
      # * Create Background
      #--------------------------------------------------------------------------
      def create_background
        @sprite1 = Sprite.new
        sprite_name = Racheal_Title::CHANGE_BACKGROUND ? get_title(1) : $data_system.title1_name
        @sprite1.bitmap = Cache.title1(sprite_name)
        @sprite2 = Sprite.new
        sprite_name = Racheal_Title::CHANGE_FOREGROUND ? get_title(2) : $data_system.title2_name
        @sprite2.bitmap = Cache.title2(sprite_name)
        center_sprite(@sprite1)
        center_sprite(@sprite2)
      end
      #--------------------------------------------------------------------------
      # * Get Title Sprite Name
      #--------------------------------------------------------------------------
      def get_title(num)
        title = 0
        if Racheal_Title::CHECK_ALL_SAVES
          #Check all saves
          for i in 0...DataManager.savefile_max
            header = DataManager.load_header(i)
            next unless header and header[:title]
            title = [title, header[:title]].max
          end
        else
          #Check latest save
          header = DataManager.load_header(DataManager.latest_savefile_index)
          if header and header[:title]
            title = [title, header[:title]].max
          end
        end
        #---
        if Racheal_Title::USE_FILENAMES
          #convert number to name
          case num
          when 1
            return Racheal_Title::BACKGROUND_NAMES[title]
          when 2
            return Racheal_Title::FOREGROUND_NAMES[title]
          end
        else
          return title.to_s
        end
      end
    end


    Credit
    - Racheal

    Author's Notes
    Free for commercial and non-commercial use. Just credit me (and let me know if you use it, just because). There's really not too much to this script. Version 1.1 features increased compatibility with save systems thanks to estriole's tip.

    As this is a script that modifies the save header, it will not work with saves created before this script was installed.
     
    Last edited by a moderator: Dec 18, 2016
    #1
    Archeia, Kes and NPC like this.
  2. NPC

    NPC Auteurist in this world Veteran

    Messages:
    1,312
    Likes Received:
    190
    Location:
    Victoria, Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    This. Is cool.
     
    #2
  3. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,588
    Likes Received:
    10,507
    First Language:
    English
    Primarily Uses:
    RMVXA
    I'm really pleased to see this, and will be using it - if I can work out how.  Trouble is I'm a complete script novice, so I was wondering if you'd mind talking me through what it is I have to do.

    I can see that I use e.g. variable 5.  Let us suppose that I want to introduce the characters into the title screen as the player meets them.  Actor 1 is already present, so can be part of the title screen from the get go.  Actor 2 then comes along.  Presumably I have an image in the Graphics/Pictures folder which I want to incorporate.  How do I set the event so that the variable calls that one up?  Is the process for subsequent actors identical?  What happens if I kill off a character - is it possible to remove a picture from somewhere in the middle of the sequence?

    I'm sorry the questions are so basic, but my knowledge of scripts hovers around the level of an idiot.

    EDIT

    Have I been trying to make this too complicated?  Do I just need a series of title pictures (i.e. the whole thing including the actor/actors) and it's this which is called up, not images to be added to the basic?  If so, I still need to know how to event the variable so that it calls up the correct screen.
     
    Last edited by a moderator: Jun 26, 2013
    #3
  4. Yato

    Yato (aka Racheal) Veteran

    Messages:
    826
    Likes Received:
    344
    Location:
    Canada
    Your edit is correct. This doesn't add more images to the title screen; it just changes the ones that exist. You have a few different options to how you want to use it.


    By default, the Ace title screen consists of two images. You can choose to change one, the other, or both. So you could have a image that has the background to the title screen, and then a layer that has all your actors. In that case, you'd probably only want to change the foreground and make that your actor images.


    As far as setting which one for the variable, you have a couple options as well. You can either name the images exactly what the variable will be. So 0 for the beginning of the game, 1 for your next one, etc. You can also set up the array of filenames in the customization section.


    FOREGROUND_NAMES = ["OneActor", "TwoActors", "PlotTwist"]


    So the foreground image would be the file named OneActor when the variable is 0, TwoActors when it is 1, and PlotTwist when it is 2.


    Hopefully this makes sense.
     
    #4
  5. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,588
    Likes Received:
    10,507
    First Language:
    English
    Primarily Uses:
    RMVXA
    Almost.  I have images named Title01, Title02 etc. (I'm so original!!) which I have put into the appropriate bit of the script.  What I am unsure about is exactly what I input for the event command.  Is it as simple and straightforward as

    select Variable 5

    operation - Add

    operand - 1

    and do that each time that I want the screen to change, so that it moves from e.g. Title02 to Title03?
     
    #5
  6. Yato

    Yato (aka Racheal) Veteran

    Messages:
    826
    Likes Received:
    344
    Location:
    Canada
    Correct. That's all there is to it.
     
    #6
  7. Ceodore

    Ceodore Villager Member

    Messages:
    12
    Likes Received:
    0
    Location:
    Florianópolis, SC, Brazil
    First Language:
    Portuguese
    Very nice extra do add, you could make the title change a goal within the game, like it is on Chaos Rings, when you defeat PiuPiu.
     
    #7
  8. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,588
    Likes Received:
    10,507
    First Language:
    English
    Primarily Uses:
    RMVXA
    Am back home, have tried it all out, and it works perfectly.  Thank you - you have a definite user here!
     
    #8
  9. Kaitrinn

    Kaitrinn Warper Member

    Messages:
    2
    Likes Received:
    0
    First Language:
    English
    Hey. I know this is super old but I can't seem to use this script because it is all on one line. I have little scripting knowledge and I don't know how to space it to get it to work. I'd appreciate it if someone could point me to a way to use this.
     
    #9
  10. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,729
    Likes Received:
    7,583
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    Unfortunately, when the forum software was switched a while back, this happened to most (all?) scripts posted here. The only way it can be fixed is if the creator fixes it. Probably what I would do is do a google search to see if it is posted somewhere else.
     
    #10
  11. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,588
    Likes Received:
    10,507
    First Language:
    English
    Primarily Uses:
    RMVXA
    You could also pm Yato and ask her if she would be able to reupload the script or provide a link.
     
    #11
  12. Kaitrinn

    Kaitrinn Warper Member

    Messages:
    2
    Likes Received:
    0
    First Language:
    English

    I looked everywhere for it but everything would just lead right back to this post. It was a last resort since I have no knowledge of how to script, but I ended up just pressing enter wherever I thought appropriate. Somehow it actually functions the way it's supposed to. So it's fixed now, just using a pretty strange method.
     
    #12
  13. mlogan

    mlogan Global Moderators Global Mod

    Messages:
    13,729
    Likes Received:
    7,583
    Location:
    Texas
    First Language:
    English
    Primarily Uses:
    RMMV
    Glad that worked, and glad this was a short script. Unfortunately, some of the scripts this has happened to were very long.
     
    #13
  14. DeathByGames

    DeathByGames Swaggy Developer Member

    Messages:
    23
    Likes Received:
    0
    First Language:
    English
    Okay, I'm a complete idiot when it comes to scripts. I've put the script into my script editor, but can anybody help me access it in game?
     
    #14
  15. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,588
    Likes Received:
    10,507
    First Language:
    English
    Primarily Uses:
    RMVXA
    I'm not sure what you mean by 'access it in game'. However, assuming you mean use it in general -
    1. Go to line 27 and put in there the number of the variable you will be using. Make sure you name the variable so that you don't use it for anything else.
    2. Go to lines 30 and 31. By Background and Foreground, she means whether your images are going to be in Titles1 and/or in Titles2. e.g. If you are using only one image which changes, then put them in Titles2, change line 30 to read false and leave line 31 as true. Adjust this to your actual requirements.
    3. Go to line 35. This is likely to be false.
    4. Go to lines 40 and 41 and put in there the names of the image files you will be using. Make sure each name is inside quote marks and separated from the next by a comma. If you are not using one of the lines, e.g. background, leave the it like this ["", ""] Where you are using one, make sure the titles you put in are exactly the same as the the image file titles.
    Once you've done all that, you're set to go.

    At the point you want the image to change, do an event which increases the variable you designated in line 27 by one. And that's it. You don't need to do anything else. The image will move to the next one in the list you provided at lines 40/41
     
    #15
    DeathByGames likes this.
  16. DeathByGames

    DeathByGames Swaggy Developer Member

    Messages:
    23
    Likes Received:
    0
    First Language:
    English
    Oh thanks so much. I'm so used to working with scripts that require the "Script" function in events that I forgot about the normal variables.
     
    #16
  17. CarlosDavilla

    CarlosDavilla The Insolent One Veteran

    Messages:
    35
    Likes Received:
    5
    Location:
    Brazil
    First Language:
    Portuguese
    Primarily Uses:
    RMVXA
    Thanks. That's just something I really needed.
     
    #17

Share This Page