• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] Adding and removing choices?

  • 72
    Posts
    6
    Years
    • Seen Jan 24, 2021
    Hello all. I have been having trouble with this problem for some time now. I wish to make a list containing a collection of choices that can be added or removed from the list at will. I was hoping I could activate the options with a Switch, but that doesn't seem to work. The option i want to remove still seems to take up a sort of "space". And I can't seem to add anything to the list of choices. I'm not sure if I'm actually doing it right, and I don't know what else to try. How would one " push" and "pull" a choice into an array of choices? Thank you very much for any help in advance.
     
    What does your code look like? I'd recommend copying how PScreen_PokemonStorage#pbStartScene works, i.e. (simplified):

    Code:
                commands = []
                cmdSummary  = -1
                cmdDebug = -1
                commands[cmdSummary=commands.length]  = _INTL("Summary")
                commands[cmdDebug=commands.length]    = _INTL("Debug") if $DEBUG
                command=pbShowCommands(helptext,commands)
                if cmdSummary>=0 && command==cmdSummary   # Summary
                  pbSummary(selected,@heldpkmn)
                elsif cmdDebug>=0 && command==cmdDebug   # Debug
                  pbPokemonDebug((@heldpkmn) ? @heldpkmn : pokemon,selected,heldpoke)
                end

    You can see here that the debug option is only added if $DEBUG is set. Is that what you're trying to do?
     
    I tried the code, but I keep getting an "undefined local variable or method 'command' " error. How do I fix it?
     
    Again, you'd have to show your code to get any help. Although it won't be from me, you'll just have to go look at the code I was paraphrasing and work it out yourself. Or at the very least come back with some sensible questions, talking about undefined local variables suggests you don't know Ruby, but I don't have the time or inclination to teach you—try Googling.

    EDIT: That was a bit harsh, but I really do recommend that you try to learn enough Ruby to understand what an undefined variable is; and also get into the habit of posting your code (short snippets rather than hundreds of lines).
     
    Last edited:
    Maybe using switches, yearh.

    Check what FL did about his HUD script, to get "push and pull" effect, where the player press P buttom into overworld (if player haves at least one pokemon):
    Code:
    class Scene_Map
      alias hud_update update
      
      def update
        hud_update
        if Input.trigger?(Input::P) && $Trainer.party.length>0
          $game_switches[HUD]=!$game_switches[HUD]
        end
      end
    end

    Also, what he did about the code for switch:
    Code:
        # When above 0, only displays HUD when this switch is on.
        SWITCHNUMBER = 0
    
        def showHUD?
          return (
            $Trainer &&
            (SWITCHNUMBER<=0 || $game_switches[SWITCHNUMBER]) &&
            (!DRAWONLYINMENU || $game_temp.in_menu)
          )
        end
     
    Last edited:
    Back
    Top