• 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!
  • Cyndy, May, Hero (Conquest), or Wes - 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] Sell Pokémon?

  • 20
    Posts
    6
    Years
    • Seen Sep 4, 2024
    Sell Pok?mon?

    Is there a way to make it so that you can sell pok?mon in your game?

    I want to be able to have my player sell pok?mon to a Mart or NPC for different amounts of money depending on species but I'm not sure how I would do it. If someone could give me some suggestions or even point me in the direction of a script I can use I'd be very grateful.
     
    If you have a script that lets the player choose a Pok?mon in their party, another that removes a Pok?mon from the party, and a third that adds money then it should be simple enough to compose them together.

    In hand-wavy code:

    Code:
    speciesMoney = {
      :BULBASAUR => 1,
      :IVYSAUR => 2,
      :VENUSAUR => 3 # etc
    }
    pkmn = choosePartyPokemon
    if pkmn:
      money = speciesMoney[pkmn.species]
      if money:
        if yesNo(_INTL("Sell your {1} for {2}?", pkmn.name, money))
          removePokemon(pkmn)
          giveMoney(money)
        end
      else
        message(_INTL("Sorry, we aren't looking to buy {1}.", pkmn.name))
      end
    end

    None of the functions I mentioned exist with those names (as far as I know), but hopefully it's obvious what they do:
    * choosePartyPokemon => lets the player pick a Pok?mon in their party, or returns nil if they cancel.
    * yesNo => prompts the player to answer a question with yes or no, and returns true if yes, and false if no.
    * removePokemon => removes a particular Pok?mon from the party (the chosen one).
    * addMoney => gives the player money.
    * message => shows a message.

    I'm also assuming that pkmn.species is a symbol that refers to the species, e.g. it contains values that look like the keys of speciesMoney; and that pkmn.name is a string.
     
    Last edited:
    Thanks so much! I had no idea where to start but your reply gave me the jumping off point I needed to cobble together a script!
     
    Sure! I'm still new at this, so I'm sure it can be improved on, but this is what worked for me!

    Spoiler:
     
    Back
    Top