Settings Menu

● ARCHIVED · READ-ONLY
Started by Holy87 3 posts View original ↗
  1. options.png
    Settings Menu
    v1.1, by Holy87

    Features

    This Settings Menu is different from the others, because it comes with no options, but it is full-modular and full-customizable both from the user and the other scripters, in the easiest way possible.

    Users can create game options from variables, switches and lunatic modes (code scirpt)

    Scripters can integrate their script in this settings menu to implement custom options (battle system options, internet options, etc...)

    What options you can make?

    • ON/OFF options for switches
    • Variables, to make options with multiple states (switching with left and right buttons)
    • Variables selected by popups, when the states are too much to show all in a single line
    • Variables selected by gauges, that also include switches if press ENTER
    • Separators, to separate settings categories
    What can I use?

    • Game Switches and Variables
    • Universal data stored in $game_settings class (see my support module)
    • script for lunatic mode
    • Custom popup windows and effects
    You can also choice if show the settings menu in the Scene_Title, Scene_Menu or in both scenes.

    How to Use

    Adding options to the list is simple, and you can do it in the script configuration or from methods. All you have to do is to insert hash with datas in the ELEMENTS array, in the configuration section of the script. Let's see some examples.

    To add separators

    {:type => :separator, :text => "This is a separator"}To add switch options

    {:type => :switch, :text => "Option name", :sw => 10, :on => "ON", :off => "OFF", :help => "Activates the option"}Text is the showed text, :sw the Switch ID, :on and :off the options showed and :help the text showed in the help window.

    switch1.png

    To add a variable option

    {:type => :variable, :text => "Option name", :var => 2, :max => 5, :help => "Change the option value"}where :var is the variable ID and :max the max value. So we have an option where we can select 0,1,2,3,4 or 5.

    variable.png

    What if we want custom values?

    You can use this code

    {:type => :variable, :text => "Difficulty", :var => 5,:help => "Set up the game difficulty.",:values => ["Easy", "Normal", "Hard", "Extreme"] }Where values are all the values showed. If there are too many values to show in a single line, you can add another attribute :use_popu => true to force to show popup. Then, pressing the action button, the values are shown like this:

    screenshot_2.png

    Lunatic settings

    Spoiler
    Global options: If you set a switch ID or variable not like an integer number, but as
    a string or a symbol, the option is seen like global and will be saved in $game_settings.
    You can enable or disable the options in 2 ways:

    • $game_system.option_enable(tag, true/false) enables or disables the game option, using this code in a call script or other scripts.
    • The <tag> parameter is the option tag defined in the option configuration :)tag => :option_name) using :condition => "condition" in the option configuration. For example, :condition => "$game_switches[55] == true" will allow the option only if the switch 55 is true
    Setting the type as :advanced, it will be executed a code when the player press enter on him. Example:
    {:type => :advanced, method => :change_scene}Then you may define the change_scene method in the Option class:

    Code:
    class Option  def change_scene    SceneManager.call(My_Scene)  endend


    For 3rd party scripters

    Spoiler
    It is useful to scripters to add game options to proper scripts directly in this
    settings menu, instead of creating apart.For the scripters, I've created 8 categories where insert your options:

    • Generic, the same part defined by the user (as no category)
    • Appearance, like themes and wallpapers
    • Audio, for music and sounds
    • Game, for game options like battle speed and difficulty level
    • Graphic, like screen resolution and special effects
    • Commands, for game controls
    • System, for techincal configurations
    • Internet, for the online functionalities
    The categories will have a dedicated separator automatically inserted (all but the generic category).

    To add an option in those categories, for every option you may pass the hash (defined like the previous options) in the respective methods:

    if $imported["H87_Options"]

    to check if the script exists in the project, then use:

    Code:
    H87Options.push_system_option(hash)H87Options.push_generic_option(hash)H87Options.push_game_option(hash)H87Options.push_graphic_option(hash)H87Options.push_sound_option(hash)H87Options.push_appearance_option(hash)H87Options.push_keys_option(hash)H87Options.push_internet_option(hash)

    to add the option in the settings menu.

    Download

    Core script: Download from Github or my blog.

    Windowskin plugin: Coming soon

    Audio plugin: Coming soon

    Difficulty plugin: Coming soon

    FAQ

    Q: Can I use this script for my commercial project?

    A: Yes, you can. all my scripts are distributed under CC-BY license. You just have to credit me.

    Q: What if I find some bugs?

    A: You can post a request here or, if you have also the fix, pull a commit on github and I will add it into the main branch.

    Q: What if I make a plugin for this script?

    A: You can post it in this topic and I will add it into the first post and in my blog.
  2. Is it possible to use script calls in your menu?

    I added your menu on Title Screen, but right now is on last place (New game, Continue, Shutdown, Settings). I would like to move your "Settings" before Shutdown. How can i do that?

    Also, I see that in script you have set up elements that will be shown in Settings windows, but when i run game all elements are hidden, except "Go to debug". Why other elements are not shown?

    menu-screen.jpg
  3. Got an error on line line 546, undefined method [] for NilClass. I commented it out and there didn't seem to be any other issues.

    line 546: next if $game_settings[option.id] != nil

    Also is there a way to customize values? I.e. instead of the default difficulty:

    :values => ["Easy","Normal","Hard"],#values 0, 1 and 2

    I would like to set it up so the values are 1, 2, and 4. This is because the damage formula is based on these values in the damage formula with 2 being default, 1 being "half damage" and 4 being "double damage".

    Although, being able to use a common event upon exiting the settings would also work.

    EDIT: I noticed an error with the variable settings. I could set it to Easy, Medium, Hard or "Other", which is to say it was all grayed out. If you go to the "Other" setting, the value would be 3. I'm not familiar with Ruby, but I'm guessing it's because the max value is based on size of the array. Since there are three values (0, 1, and 2) I suppose that means the size is three, even though the largest value is 2. I just subtracted 1 from max on initialization.

    Code:
      def init_variable(hash)
        @distance = hash[:distance].nil? ? 1 : hash[:distance]
        @variable = hash[:var]
        @need_popup = hash[:open_popup]
        @popup = eval(hash[:popup]) if hash[:popup]
        @default = 0 if @default.nil?
        if hash[:values].nil?
          @values = []
          @max = hash[:max] - 1
          for i in 0..@max
            @values.push(i)
          end
        else
          @values = hash[:values]
          @max = @values.size - 1
        end
      end

    This is for personal use and it's probably not the best way to solve the problem, but I thought I'd share this too. Basically it calls a common event whenever you exit the menu. In my case, I'm using it to change the player's defense values depending on the difficulty value.

    Code:
    class Scene_MenuBase < Scene_Base
      def dispose_background
        @background_sprite.dispose
        $game_temp.reserve_common_event(16)
      end
    end

    EDIT 2: Found another error. I was on a custom option and accidentally hit the right key--this caused the game to crash. I guess the script was treating it like a switch or variable?

    Code:
      #--------------------------------------------------------------------------
      # * Incrementa il valore dell'opzione
      #--------------------------------------------------------------------------
      def increment
        if @type == :switch
          toggle
        else
          set_switch(true)
          self.value += @distance
          if :variable
            self.value = 0 if self.value > @max
          else
            self.value = @max if self.value > @max
          end
        end
      end

    I changed it to this:

    Code:
      #--------------------------------------------------------------------------
      # * Incrementa il valore dell'opzione
      #--------------------------------------------------------------------------
      def increment
        if @type == :switch
          toggle
        end
        if @type == :variable
          set_switch(true)
          self.value += @distance
          if :variable
            self.value = 0 if self.value > @max
          else
            self.value = @max if self.value > @max
          end
        end
      end

    Same with the decrement section. The game no longer crashes if I accidently push left or right on an Option class field.