• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Custom Option in Options Menu?

39Gamer

39Games
55
Posts
10
Years
  • I'd like to add a new option to the options menu, yes or no option affecting a global switch in the game.
    how could i do this?
     
    94
    Posts
    11
    Years
    • Seen May 4, 2018
    I tried doing that but it didn't work. I was able to do it with a variable though, so it's kind of the same.

    in script PokemonOptions

    below
    Code:
    attr_accessor :language

    add

    Code:
    attr_accessor :custom

    Then under
    Code:
    @PokemonOptions=[

    add

    Code:
    EnumOption.new(_INTL("Custom"),[_INTL("On"),_INTL("Off")],
              proc { $PokemonSystem.custom},
              proc {|value|  $PokemonSystem.custom=value }
           ),

    Then you can make an event like this

    Custom Option in Options Menu?


    Or whatever you may need to do with it. If you choose "On" in Options, its value will be 0, and if you select "Off", it will be 1. You can name them whatever you want.


    Note that I tried this first:

    Code:
              proc { $game_variables[51] },
              proc {|value|  $game_variables[51]=value }
    But it didn't work either.


    Hopefully someone with more expertise will post how to do it with a switch if this doesn't work for what you need.
     
    1,224
    Posts
    10
    Years
  • I tried doing that but it didn't work. I was able to do it with a variable though, so it's kind of the same.

    in script PokemonOptions

    below
    Code:
    attr_accessor :language

    add

    Code:
    attr_accessor :custom

    Then under
    Code:
    @PokemonOptions=[

    add

    Code:
    EnumOption.new(_INTL("Custom"),[_INTL("On"),_INTL("Off")],
              proc { $PokemonSystem.custom},
              proc {|value|  $PokemonSystem.custom=value }
           ),

    Then you can make an event like this

    Custom Option in Options Menu?


    Or whatever you may need to do with it. If you choose "On" in Options, its value will be 0, and if you select "Off", it will be 1. You can name them whatever you want.


    Note that I tried this first:

    Code:
              proc { $game_variables[51] },
              proc {|value|  $game_variables[51]=value }
    But it didn't work either.


    Hopefully someone with more expertise will post how to do it with a switch if this doesn't work for what you need.

    You're on the right track. You do have to add
    Code:
    attr_accessor :custom
    but you have to remember what an accessor actually is. It's just allowing you to read and write a variable from outside the class, which means the variable has to be initialized. So under this
    Code:
    def initialize
        @textspeed   = 1   # Text speed (0=slow, 1=mid, 2=fast)
        @battlescene = 0   # Battle scene (animations) (0=on, 1=off)
        @battlestyle = 0   # Battle style (0=shift, 1=set)
        @frame       = 0   # Default window frame (see also $TextFrames)
        @textskin    = 0   # Speech frame
        @font        = 0   # Font (see also $VersionStyles)
        @screensize  = (DEFAULTSCREENZOOM.floor).to_i # 0=half size, 1=full size, 2=double size
        @language    = 0   # Language (see also LANGUAGES in script PokemonSystem)
    we have to initialize the variable. We want it to initialize to whatever the game variable is, but you have to remember that you can access the options menu from the loading screen, before game variables are loaded/defined. So add something like this
    Code:
    if $game_variables
            @custom = 0
        end

    So now we have it initialized. To add the option to change it, we'll just add it to the list of EnumOptions. But hold on, we still have to remember you can access the options from the loading screen, so we'll want to just add it in conditionally. After you last option (looks like this in v14)
    Code:
    EnumOption.new(_INTL("Screen Size"),[_INTL("Small"),_INTL("Medium"),_INTL("Large")],
              proc { $PokemonSystem.screensize },
              proc {|value|
                 oldvalue=$PokemonSystem.screensize
                 $PokemonSystem.screensize=value
                 $ResizeOffsetX=0
                 $ResizeOffsetY=0
                 pbSetResizeFactor([0.5,1.0,2.0][value])
                 if value!=oldvalue
                   ObjectSpace.each_object(TilemapLoader){|o| next if o.disposed?; o.updateClass }
                 end
              }
           )
    # ------------------------------------------------------------------------------
        ]
    Add something like this (I'm just switching it between 0 and 1, you can do whatever you need)
    Code:
    if $game_variables
          @PokemonOptions.push(EnumOption.new(_INTL("Custom"),[_INTL("Zero"),_INTL("One")],
                proc { $PokemonSystem.custom},
                proc {|value| 
                $PokemonSystem.custom=value
                $game_variables[XX]=value #XX is your chosen variable number
                } 
              ))
          end
    In your example LenSho, you are intending to set your thing to true/false (at least it appears so), but all that is actually happening here is it sets it to 0 or 1 (the index of the choice). You just have to add in a bit extra taking these into account
    Code:
     if value==0
    $game_switches[XX]=true
    else
    $game_switches[XX]=false
    end
     
    Back
    Top