• 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.

[Scripting Question] Preventing Custom Option on Loading Screen?

  • 132
    Posts
    9
    Years
    I've added an option to quicksave when pressing P. Since it's dependent on a game switch being turned on, loading up the option menu from the loading screen causes a crash, as no variables or switches are defined yet.

    Crash:
    Spoiler:


    In this thread (2014), it's suggested you use a condition when defining your accessor like so:
    Code:
    if $game_variables
          @quicksave = 0
        end
    whilst doing the same when adding the option:
    Code:
    if $game_variables
            EnumOption.new(_INTL("Quicksaving (P)"),[_INTL("Off"),_INTL("On")],
                proc { $PokemonSystem.quicksave},
                proc {|value| 
                $PokemonSystem.quicksave=value
                $game_switches[240]=value
                 if value==0
                  $game_switches[240]=false
                 else
                  $game_switches[240]=true
                 end
                } 
            )
    end

    Clearly this is not up-to-date. What would be the correct way of checking whether you're in the loading screen options or in-game options? Thanks!!
    PS: whoever programmed this inkay to bob on my screen should be liable for the 5 aneurysms i've had in the last half hour
     

    Sir_Tman

    Overworked game Dev
  • 201
    Posts
    8
    Years
    Assuming you are using the latest version of essentials in PScreen_Options look around line 390 for pbStartScene and you can put the Red anywhere in there depending where you want this option to appear in the list.

    Code:
    def pbStartScene(inloadscreen=false)
        [COLOR="DarkOrange"][I]...Stuff that draws graphics...[/I][/COLOR]
        [COLOR="green"]# These are the different options in the game. To add an option, define a
        # setter and a getter for that option. To delete an option, comment it out
        # or delete it. The game's options may be placed in any order.[/COLOR]
        @PokemonOptions = [
    [COLOR="red"]       
           EnumOption.new(_INTL("Quicksave"),[_INTL("On"),_INTL("Off")],
             proc {$Game_Switches.switch[240]},
             proc {|value| $Game_Switche.switch[240]=value}
             ),[/COLOR]
    
           EnumOption.new(_INTL("Screen Border"),[_INTL("Off"),_INTL("On")],
             proc { $PokemonSystem.border },
             proc {|value|
               oldvalue = $PokemonSystem.border
               $PokemonSystem.border = value
               if value!=oldvalue
                 pbSetResizeFactor($PokemonSystem.screensize)
                 ObjectSpace.each_object(TilemapLoader){|o| o.updateClass if !o.disposed? }
               end
             }
           )
        ]
     

    Sir_Tman

    Overworked game Dev
  • 201
    Posts
    8
    Years
    Sorry, that won't work as game varriables havent been initalized.
    You're actually going have to do it this way. All the red in the following places

    In PScreen_Options

    Code:
    class PokemonSystem
      attr_accessor :textspeed
      attr_accessor :battlescene
      attr_accessor :battlestyle
      attr_accessor :frame
      attr_accessor :textskin
      attr_accessor :font
      attr_accessor :screensize
      attr_accessor :border
      attr_accessor :language
      attr_accessor :runstyle
      attr_accessor :bgmvolume
      attr_accessor :sevolume
      attr_accessor :textinput
      attr_accessor :backup
      attr_accessor :maxBackup
      attr_accessor :backupNames
    [COLOR="red"]  attr_accessor :quicksave[/COLOR]
    
      def initialize
        @textspeed   = 2   # Text speed (0=slow, 1=normal, 2=fast)
        @battlescene = 0   # Battle effects (animations) (0=on, 1=off)
        @battlestyle = 0   # Battle style (0=switch, 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
        @border      = 0   # Screen border (0=off, 1=on)
        @language    = 0   # Language (see also LANGUAGES in script PokemonSystem)
        @runstyle    = 0   # Run key functionality (0=hold to run, 1=toggle auto-run)
        @bgmvolume   = 100 # Volume of background music and ME
        @sevolume    = 100 # Volume of sound effects
        @textinput   = 1   # Text input mode (0=cursor, 1=keyboard)
        [COLOR="red"]@quicksave   = 0   # Quicksave (0=off, 1=on)[/COLOR]
      end
    
      def textskin
        @textskin = 0 if !@textskin
        return @textskin
      end
    
      def border
        @border = 0 if !@border
        return @border
      end
    
      def language
        @language = 0 if !@language
        return @language
      end
    
      def runstyle
        @runstyle = 0 if !@runstyle
        return @runstyle
      end
    
      def bgmvolume
        @bgmvolume = 100 if !@bgmvolume
        return @bgmvolume
      end
    
      def sevolume
        @sevolume = 100 if !@sevolume
        return @sevolume
      end
    
      def textinput
        @textinput = 0 if !@textinput
        return @textinput
      end
    
      def tilemap; return MAPVIEWMODE; end
        
    [COLOR="Red"]  def quicksave
        @quicksave = 0 if !@quicksave
        return @quicksave
      end[/COLOR]
    end

    Then like my previous methord before you're going to have to find pbStartScene under PokemonOptionScene and add the following.

    Code:
     def pbStartScene(inloadscreen=false)
        [COLOR="Yellow"]...Graphics Stuff...[/COLOR]
       [COLOR="Green"] # These are the different options in the game. To add an option, define a
        # setter and a getter for that option. To delete an option, comment it out
        # or delete it. The game's options may be placed in any order.[/COLOR]
        @PokemonOptions = [
           EnumOption.new(_INTL("Text Speed"),[_INTL("Slow"),_INTL("Normal"),_INTL("Fast")],
             proc { $PokemonSystem.textspeed },
             proc {|value|
               $PokemonSystem.textspeed = value 
               MessageConfig.pbSetTextSpeed(pbSettingToTextSpeed(value)) 
             }
           ), 
           
          [COLOR="Red"] EnumOption.new(_INTL("Quicksave"),[_INTL("On"),_INTL("Off")],
           proc { $PokemonSystem.quicksave },
           proc {|value| 
             $PokemonSystem.quicksave = value 
             }
           )[/COLOR]
        ]
     
  • 132
    Posts
    9
    Years
    Sorry, that won't work as game varriables havent been initalized.
    You're actually going have to do it this way. All the red in the following places

    In PScreen_Options

    Code:
    class PokemonSystem
      attr_accessor :textspeed
      attr_accessor :battlescene
      attr_accessor :battlestyle
      attr_accessor :frame
      attr_accessor :textskin
      attr_accessor :font
      attr_accessor :screensize
      attr_accessor :border
      attr_accessor :language
      attr_accessor :runstyle
      attr_accessor :bgmvolume
      attr_accessor :sevolume
      attr_accessor :textinput
      attr_accessor :backup
      attr_accessor :maxBackup
      attr_accessor :backupNames
    [COLOR="red"]  attr_accessor :quicksave[/COLOR]
    
      def initialize
        @textspeed   = 2   # Text speed (0=slow, 1=normal, 2=fast)
        @battlescene = 0   # Battle effects (animations) (0=on, 1=off)
        @battlestyle = 0   # Battle style (0=switch, 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
        @border      = 0   # Screen border (0=off, 1=on)
        @language    = 0   # Language (see also LANGUAGES in script PokemonSystem)
        @runstyle    = 0   # Run key functionality (0=hold to run, 1=toggle auto-run)
        @bgmvolume   = 100 # Volume of background music and ME
        @sevolume    = 100 # Volume of sound effects
        @textinput   = 1   # Text input mode (0=cursor, 1=keyboard)
        [COLOR="red"]@quicksave   = 0   # Quicksave (0=off, 1=on)[/COLOR]
      end
    
      def textskin
        @textskin = 0 if !@textskin
        return @textskin
      end
    
      def border
        @border = 0 if !@border
        return @border
      end
    
      def language
        @language = 0 if !@language
        return @language
      end
    
      def runstyle
        @runstyle = 0 if !@runstyle
        return @runstyle
      end
    
      def bgmvolume
        @bgmvolume = 100 if !@bgmvolume
        return @bgmvolume
      end
    
      def sevolume
        @sevolume = 100 if !@sevolume
        return @sevolume
      end
    
      def textinput
        @textinput = 0 if !@textinput
        return @textinput
      end
    
      def tilemap; return MAPVIEWMODE; end
        
    [COLOR="Red"]  def quicksave
        @quicksave = 0 if !@quicksave
        return @quicksave
      end[/COLOR]
    end

    Then like my previous methord before you're going to have to find pbStartScene under PokemonOptionScene and add the following.

    Code:
     def pbStartScene(inloadscreen=false)
        [COLOR="Yellow"]...Graphics Stuff...[/COLOR]
       [COLOR="Green"] # These are the different options in the game. To add an option, define a
        # setter and a getter for that option. To delete an option, comment it out
        # or delete it. The game's options may be placed in any order.[/COLOR]
        @PokemonOptions = [
           EnumOption.new(_INTL("Text Speed"),[_INTL("Slow"),_INTL("Normal"),_INTL("Fast")],
             proc { $PokemonSystem.textspeed },
             proc {|value|
               $PokemonSystem.textspeed = value 
               MessageConfig.pbSetTextSpeed(pbSettingToTextSpeed(value)) 
             }
           ), 
           
          [COLOR="Red"] EnumOption.new(_INTL("Quicksave"),[_INTL("On"),_INTL("Off")],
           proc { $PokemonSystem.quicksave },
           proc {|value| 
             $PokemonSystem.quicksave = value 
             }
           )[/COLOR]
        ]

    Thanks for the reply. So $PokemonSystem.quicksave is replacing the game switches, which means no crash when accessing from the loading screen's options. But, now I don't know how to actually quicksave from within game. This code is in Scene_Map:
    Code:
    if Input.trigger?(Input::P)
     [COLOR="Red"]  if $game_switches[240][/COLOR]
          pbCommonEvents(13) #this is just pbSave
       end
    end
    Since the red is no longer being used, how can I make a check to see if @quicksave == 1? I believe Scene_Map is where I'd have to leave this script. Does that make sense?
     

    Sir_Tman

    Overworked game Dev
  • 201
    Posts
    8
    Years
    Just this.
    Code:
    if Input.trigger?(Input::P)
       [COLOR="Red"]if $PokemonSystem.quicksave == 0[/COLOR]
          pbCommonEvents(13) #this is just pbSave
       end
    end

    AND! Make sure you firstly have the P key registered in PSystem_Controls
     
    Last edited:
    Back
    Top