• 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] Sell Pokémon?

20
Posts
5
Years
  • Age 31
  • Seen Jun 30, 2023
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.
 
1,403
Posts
10
Years
  • Seen Apr 18, 2024
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:
20
Posts
5
Years
  • Age 31
  • Seen Jun 30, 2023
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!
 
1,403
Posts
10
Years
  • Seen Apr 18, 2024
That's great to hear! Maybe you'd like to share what you came up with for anybody who reads this thread in the future? :)
 
20
Posts
5
Years
  • Age 31
  • Seen Jun 30, 2023
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