• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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] [V20.1/21] How do I change SAFARI_STEPS Based on Switch Status?

  • 1
    Posts
    1
    Years
    • He/Him
    • USA
    • Seen Sep 30, 2023
    I simply want to change it to 0 if $game_switches[60] is on. I tried doing this in "settings":

    Code:
      if $game_switches[60]
        SAFARI_STEPS                               = 0
      else
        SAFARI_STEPS                               = 600
      end

    But that gives an error (Undefined method [] for nil:NilClass) that implies that game_switches[60] does not exist yet when compiling the scripts. Is there another way I can edit this value to what I want?
     
    Hello, @the_metal_invader
    Because SAFARI_STEPS is a constant, it is essentially decided before the compiling of the game, so any changes to $game_switches would not work, even if there was no error.

    To solve this, you instead have to change the line(s) where SAFARI_STEPS is is used.
    1) Ctrl Shift F, then paste "SAFARI_STEPS" in scripts
    2) There's about six or seven times this is used. Change every instance of SAFARI_STEPS (except for the line where is it assigned (ie. the line you tried to edit)), to pbGetSafariSteps, (or another method name if you wish)
    3) Let's write the method pbGetSafariSteps:

    Code:
    # Obtains the number of steps allowed in the Safari Zone
    def pbGetSafariSteps
      # Unlimited Steps if switch 60 is on, or else  600 Steps
      return $game_switches[60] ? 0 : 600
    end

    NOTE: If you don't want to mess with the original code, you can take the methods outside of the original scripts. Consult me if you're not sure how to do this
    ADVICE: Because lots of numbers are annoying, and hard to keep track of, it might help to set switch 60 to a constant, so put:
    Code:
    UNLIMITED_SAFARI_ZONE_STEPS = 60
    somewhere, and then change the "60" in the pbGetSafariSteps method to "UNLIMITED_SAFARI_ZONE_STEPS "

    Hope this helps,
    Swdfm
     
    Back
    Top