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

Adding new functions to the Trainer's PC?

  • 115
    Posts
    10
    Years
    • Seen Nov 17, 2023
    I'm trying to implement an additional function for the Trainer PC that allows the player to do their banking. While the game doesn't crash when I run it, only the item storage works, and selecting "Banking" or "Mailbox" doesn't do anything. Here is the code I changed in the PokemonStorage script:
    Spoiler:

    This is what allows the player to withdraw and deposit their money from the bank. I also added in a check for whether or not the player has opened up a bank account yet, which is determined by switch 101. If they don't have a bank account, it won't let them access the banking menus.

    I also squeezed in the "Banking" option in the pbTrainerPCMenu here:
    Spoiler:

    Long story short, I did something wrong here, but I'm not exactly sure what. Did anyone else here ever try adding in their own PC functions besides the default item storage and mailbox?
     
    Uhmmm, just to give an idea on how you do it. Perhaps you can make the mailbox through eventing? When talking to the PC, first you have two choices: Use the Storage System or check your mail, and then you put all your branches.
     
    You just have an error with your code. It's easier to spot if the code is indented properly, like so:
    Code:
    def pbTrainerPCMenu
      loop do
        command=Kernel.pbMessage(_INTL("What do you want to do?"),[
           _INTL("Item Storage"),
           _INTL("Banking"),
           _INTL("Mailbox"),
           _INTL("Turn Off")
        ],-1)
        [COLOR=Green]if command==0[/COLOR]
          pbPCItemStorage
          [COLOR=Red]if command==1
            pbPCBanking
          elsif command==2
            pbPCMailbox
          else
            break
          end[/COLOR]
        [COLOR=Green]end[/COLOR]
      end
    end
    Note my use of the
    Code:
     tags, rather than [spoiler] tags. [code] is for code. Makes sense when you think about it.
    
    The red part of this code is actually within the "[COLOR=Green]if command==0"[/COLOR] part, and as such can only be accessed when command equals 0. This chunk of code needs to be moved slightly, in a way I'm sure you can figure out for yourself.
     
    Edit: Scratch that. I was still having issues. I'll try making the changes you told me to make.
     
    Last edited:
    Update: I figured it out. A big thank you to both Maruno and lolandbeer for helping me out. :) I'll post the revised code on here for anyone else who might want to do something similar in the future.


    Code:
    def pbTrainerPCMenu
      loop do
        command=Kernel.pbMessage(_INTL("What do you want to do?"),[
           _INTL("Item Storage"),
           _INTL("Banking"),
           _INTL("Mailbox"),
           _INTL("Turn Off")
        ],-1)
        if command==0
          pbPCItemStorage
        elsif command==1
          pbPCBanking
        elsif command==2
          pbPCMailbox
        else
          break
        end
      end
    end
     
    If you were to add a new function to the PC, what would it be used for?
     
    Back
    Top