Glossary/Tips Script

Discussion in 'RGSS3 Script Requests' started by Gravemaster, Oct 28, 2019.

  1. Gravemaster

    Gravemaster Lord Veteran

    Messages:
    80
    Likes Received:
    5
    Location:
    Tripoli, Greece
    First Language:
    English
    Primarily Uses:
    N/A
    Hey. I think this is relatively easy to make, but I can't find anything similar on the net.

    Since RPG Maker uses no loading screen (where I could display tips, etc), I want a glossary/tips script, basically a new option in the main menu, where I can have entries (all of them available from the start, no need to add options for that), that when clicked on, display simple text.

    Basically I will be using this to give the player strictly technical information regarding the game's mechanics.


    #Entry name:
    "Dashing"

    #when chosen:
    "Holding down the \C[3]Shift\C[0] key while moving will make you dash, spending \C[4]Stamina Points\C[0]. When your \C[4]Stamina Points\C[0] are out (as displayed in the bottom-left corner of the screen), your dash will automatically stop,
    and you will switch back to walking. Your \C[4]Stamina Points\C[0] will automatically start refilling when you stop moving.
    You can increase your maximum \C[4]Stamina Points \C[0] by the use of perks, or certain \C[4]Elite Items]C[0] found rarely
    in the game."

    The script will be used for my Broken Reality RPG, which is free to play (https://lord-rutsah.itch.io/broken-reality). Credits will be properly given of course. Thanks for your help!
     
    #1
  2. proxydef

    proxydef Warper Member

    Messages:
    1
    Likes Received:
    0
    First Language:
    english
    it can be done without script
    how to do it? use event and try to figure out with this clue:
    "Wait", Show picture and/or show animation
     
    #2
  3. ZirconStorms

    ZirconStorms VX & VX Ace Scripts Veteran

    Messages:
    332
    Likes Received:
    108
    First Language:
    English
    Primarily Uses:
    RMVXA
  4. Gravemaster

    Gravemaster Lord Veteran

    Messages:
    80
    Likes Received:
    5
    Location:
    Tripoli, Greece
    First Language:
    English
    Primarily Uses:
    N/A
    ZirconStorms: Unfortunately I'm already using Matt's Journal (version 1.4) for lore entries etc, so using an earlier version of the script causes all manners of problems.
    proxydef: Eh... I... I don't know what to answer to that.
     
    #4
  5. A-Moonless-Night

    A-Moonless-Night WINTER IS COMING Veteran

    Messages:
    509
    Likes Received:
    364
    Location:
    New Zealand
    First Language:
    English
    Primarily Uses:
    RMVXA
    I should be able to adapt one of my own scripts for this. What do you want the windows to look like? Just a list of the terms and then an information window next to it?
     
    #5
  6. Gravemaster

    Gravemaster Lord Veteran

    Messages:
    80
    Likes Received:
    5
    Location:
    Tripoli, Greece
    First Language:
    English
    Primarily Uses:
    N/A
    If you can, sure, but it doesn't even have to be that complicated if it's too much trouble. A single list of the terms and just a big window opening and replacing the screen with a text dumb on it when one of them is selected would also be enough.
     
    #6
  7. A-Moonless-Night

    A-Moonless-Night WINTER IS COMING Veteran

    Messages:
    509
    Likes Received:
    364
    Location:
    New Zealand
    First Language:
    English
    Primarily Uses:
    RMVXA
    No worries. Here you go:
    Code:
    =begin
    #==============================================================================#
    #   AMN Glossary
    #   Version   1.01
    #   Author:   AMoonlessNight
    #   Date:     07 Nov 2019
    #   Latest:   07 Nov 2019
    #==============================================================================#
    #   UPDATE LOG
    #------------------------------------------------------------------------------#
    # 07 Nov 2019 - created the script
    #==============================================================================#
    #   TERMS OF USE
    #------------------------------------------------------------------------------#
    # - Please credit AMoonlessNight or A-Moonless-Night
    # - Free for non-commercial use
    # - Contact for commercial use
    # - I'd love to see your game if you end up using one of my scripts
    #==============================================================================#
    
    This script makes a basic glossary scene, where you can select different terms
    and see what they mean. It's pretty basic, but could also be used as a simple
    journal or a help screen.
    
    Set up the glossary in the editable region below.
    
    You can access the glossary scene by using the following:
    SceneManager.call(Scene_Glossary)
    
    There is also an option to have it in the main menu.
    
    #------------------------------------------------------------------------------#
    NOTE: It is recommended that you used Killozappit's Word Wrapping Message Boxes 
    with this script to make the text automatically wrap. 
    
    You can find it here:
    https://www.rpgmakercentral.com/topic/6964-word-wrapping-message-boxes/
    #------------------------------------------------------------------------------#
    
    =end
    
    module AMN_Glossary
    #==============================================================================
    # ** EDITABLE REGION BELOW
    #------------------------------------------------------------------------------
    #  Change the values in the area below to suit your needs.
    #==============================================================================
    
      Menu_Option = true            # whether to have the Glossary show as an option
                                    # in the menu
                                   
      Glossary_Name = "Glossary"    # what to call the option in the menu
     
      Draw_Page_Numbers = true      # whether to draw page numbers at the bottom
     
      Glossary = { 
    # Each entry should have a unique title, e.g. "Battles", "Items", "Dashing".
    
    # Each entry should have an array [] of strings, e.g. ["text"]. 
    
    # You can make multiple pages for one entry by closing off the string 
    # with " followed by a comma. 
    # E.g. ["this is page one.", "this is page two.", "page three.",]
    
    # You can use escape codes in the text to change the colour, etc. Just make
    # sure you use double slashes, e.g. \\c[3]
    
    # Don't use escape codes in the titles.
    
    # You will need to input the line breaks manually, unless you use a word
    # wrapping script (like Killozappit's).
     
     
      #"Title"  =>  ["text", "can be", "split into", "multiple pages"],
      "Dashing" =>  ["Holding down the \\C[3]Shift\\C[0] key while moving will 
    make you dash, spending \\C[4]Stamina Points\\C[0]. When your \\C[4]Stamina 
    Points\\C[0] are out (as displayed in the bottom-left corner of the screen), 
    your dash will automatically stop, and you will switch back to walking. 
    Your \\C[4]Stamina Points\\C[0] will automatically start refilling when 
    you stop moving.
    You can increase your maximum \\C[4]Stamina Points \\C[0] by the use of 
    perks, or certain \\C[4]Elite Items\\C[0] found rarely in the game."],
    #---------------------
    
      "Entry 2" => ["You can use escape codes, such as \\c[1]coloured text\\c[0].
    Just remember to put two dashes."],
    #---------------------
    
      "Entry 3" => ["You can have \\{multiple\\} pages,", "like so."],
    #---------------------
    
      "Entry 4" => ["You can use variables in the text as well. Variable 4 is
    set to \\v[4]."],
    #---------------------
    
      "Entry 5" => ["Include as many entries as you'd like."],
    #---------------------
    # Copy and paste as needed; just make sure there's a comma after each: ],
    
    #==============================================================================
    # ** END OF EDITABLE REGION
    #------------------------------------------------------------------------------
    #  Please do not edit below this point unless you know what you are doing.
    #==============================================================================
      }
    end
    
    class Window_AMNGlossary < Window_Selectable
      attr_reader :info_window
     
      def initialize(x, y)
        make_item_list
        super(x, y, window_width, window_height)
        refresh
        activate
      end
     
      def window_width
        160
      end
     
      def window_height
        Graphics.height
      end
     
      def make_item_list
        @data = AMN_Glossary::Glossary.keys
      end
     
      def item_max
        @data ? @data.size : 1
      end
     
      def draw_item(index)
        item = @data[index]
        if item
          rect = item_rect_for_text(index)
          rect.width -= 4
          draw_text(rect, item)
        end
      end
     
      def info_window=(info_window)
        @info_window = info_window
        update
      end
     
      def update
        super
        @info_window.category = @data[index] if @info_window
      end
     
    end
    
    class Window_AMNInfo < Window_Base
     
      def initialize(x, y, width, height)
        super(x, y, width, height)
        @category = nil
        setup_data
      end
    
      def setup_data
        @data = AMN_Glossary::Glossary.clone
        refresh
      end
     
      def index_max
        return 0 unless @category && @data.key?(@category)
        @data[@category].size - 1
      end
     
      def increase_index
        prev = @index
        @index = [@index + 1, index_max].min
        @index = 0 if prev == index_max
        refresh
      end
     
      def decrease_index
        prev = @index
        @index = [@index - 1, 0].max
        @index = index_max if prev == 0
        refresh
      end
     
      def category=(category)
        return if @category == category
        @category = category
        @index = 0
        refresh
      end
     
      def refresh
        contents.clear
        draw_info
      end
    
      def draw_info
        return unless @category
        item = @data[@category][@index]
        return unless item
        draw_text_ex(0, 0, item)
        reset_font_settings
        if AMN_Glossary::Draw_Page_Numbers
          page = "Page #{@index+1}/#{index_max+1}"
          c = text_size(page).width
          page.insert(0, "\\c[16]"); page.insert(11, "\\c[0]")
          draw_text_ex(contents_width - c, contents.height - line_height, page)
        end
      end
     
    end
    
    class Scene_Glossary < Scene_MenuBase
    
      def start
        super
        create_glossary_window
        create_info_window
      end
     
      def create_glossary_window
        @glossary_window = Window_AMNGlossary.new(0,0)
        @glossary_window.set_handler(:ok, method(:on_glossary_ok))
        @glossary_window.set_handler(:cancel, method(:return_scene))
        @glossary_window.select(0)
      end
     
      def create_info_window
        x = @glossary_window.x + @glossary_window.width
        width = Graphics.width - @glossary_window.width
        height = @glossary_window.height
        @info_window = Window_AMNInfo.new(x, 0, width, height)
        @glossary_window.info_window = @info_window
      end
     
      def on_glossary_ok
        @info_window.increase_index
        @glossary_window.activate
      end
     
    end
    
    class Window_MenuCommand < Window_Command
    
      alias amn_glossary_windmenucmd_addogcommands  add_original_commands
      def add_original_commands
        amn_glossary_windmenucmd_addogcommands
        if AMN_Glossary::Menu_Option
          add_command(AMN_Glossary::Glossary_Name, :amn_glossary, main_commands_enabled)
        end
      end
     
    end
    
    class Scene_Menu < Scene_MenuBase
     
      def command_amn_glossary
        SceneManager.call(Scene_Glossary)
      end
    
      alias amn_glossary_scenemenu_createcomwind create_command_window
      def create_command_window
        amn_glossary_scenemenu_createcomwind
        if AMN_Glossary::Menu_Option
          @command_window.set_handler(:amn_glossary, method(:command_amn_glossary))
        end
      end
     
    end
    

    Let me know if you have any issues. I'd also recommend having a word wrapping script for it, unless you're happy to add the line breaks in manually.
     
    Last edited: Nov 9, 2019
    #7
    ZirconStorms likes this.
  8. Gravemaster

    Gravemaster Lord Veteran

    Messages:
    80
    Likes Received:
    5
    Location:
    Tripoli, Greece
    First Language:
    English
    Primarily Uses:
    N/A
    This is perfect, thanks! Mods, you can lock the thread now, I have everything I need here.
     
    #8

Share This Page