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

help with adding a pokemon

14
Posts
14
Years
  • Seen Jun 27, 2013
I am trying to add a pokemon to the player from anouther trainer.

pbAddForeignPokemon(PBSpecies::SANDSHREW,5,_I("Jake"),_I("Sorex"),0)

if i understand from the tutorial that would work but it brings up an error everytime. I would also like to make added pokemon shiny if possible too.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
An important thing to watch out for is how the code looks when you type it into an event. The code itself is fine, but it probably looks like this:

Code:
pbAddForeignPokemon
(PBSpecies::SANDSHREW,5,_I
("Jake"),_I("Sorex"),0)
RMXP is stupid, and thinks these are three separate and unrelated lines of code, rather than one long one. What you need to do is to tell RMXP that, when it gets to the end of the first line, that there's more of that line still to come. You do this by putting the open bracket "(" at the end of the first line rather than the beginning of the second line. You also need to do something similar with the second line, but make sure it ends on a comma (an open bracket would work as well; you'll develop your own style eventually).

What you should end up with is something that looks like this:

Code:
pbAddForeignPokemon(
PBSpecies::SANDSHREW,5,
_I("Jake"),_I("Sorex"),0)
The open bracket and the comma are useful things, because they indicate that the line hasn't finished yet, and the continuation is on the next line. There are one or two other such characters (probably), but you don't need to worry about them as the open bracket and comma will work for you just fine - they do for me.

The alternative is to use ExtendText (the .exe in the game's folder) to make the script box much wider, allowing you to fit everything on the same line. It's certainly useful, although it's probably best if you do some clever lining as I described above, if you can afford the space.



Having said all that, though, this particular script is best used as the argument of a Conditional Branch. It will return true if the Pokémon was added, and false if not. This allows you to "deactivate" the Pokémon-giving event once it's done its job (perhaps by playing with its Self Switches).

To make the Pokémon shiny, read the wiki. There's also an example of exactly what you want in the example maps (far right NPC in the Pokémon Fan Club).
 

FL

Pokémon Island Creator
2,443
Posts
13
Years
  • Seen Apr 16, 2024
RMXP is stupid
This is a Ruby syntax problem, isn't? This language has an auto line break without use semicolon, although its support this symbol.

The big problem is that RMXP has a small box for enter script, so the alternative is ExtendText like Maruno said.
 
Back
Top