• 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!
  • It's time to vote for your favorite Pokémon Battle Revolution protagonist in our new weekly protagonist poll! Click here to cast your vote and let us know which PBR protagonist you like most.
  • 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] Giving the player a random pokemon with random level

  • 3
    Posts
    10
    Years
    • Seen Jul 15, 2020
    Hello, Essentials/RPG maker xp noob here
    So i have this event (see image attached)
    The goal is to give a random Pokemon at a random level to the player .
    Handling a random level is quite easy, i just use control variables to give me a number between 1 and 100 and asign it to a variable (26 in this case).
    To handle the random pokemon i use this code
    Code:
    $game_variables[27] = PBSpecies.getName(1+rand(PBSpecies.maxValue)).upcase
    I then display this text :
    Code:
    Hey \PN, take this \v[27], level  \v[26] .
    Which actually displays a random pokemon name and random number.
    the issue stems from this last piece of code:
    Code:
    pbAddPokemon(:$game_variables[27],$game_variables[26])
    which displays this error message

    Code:
    ---------------------------
    Pokemon Essentials
    ---------------------------
    [Pokémon Essentials version 17.2]
    
    Exception: RuntimeError
    
    Message: Script error within event 2 (coords 8,10), map 42 (Starting Lab):
    
    Exception: SyntaxError
    
    Message: (eval):1:in `pbExecuteScript'compile error
    (eval):1: syntax error
    pbAddPokemon(:pbGet(27),pbGet(26))
                        ^
    
    ***Full script:
    
    pbAddPokemon(:pbGet(27),pbGet(26))
    
    
    
    
    Interpreter:276:in `pbExecuteScript'
    
    Interpreter:1606:in `command_355'
    
    Interpreter:494:in `execute_command'
    
    Interpreter:193:in `update'
    
    Interpreter:106:in `loop'
    
    Interpreter:198:in `update'
    
    Scene_Map:163:in `follow_update'
    
    Scene_Map:161:in `loop'
    
    Scene_Map:170:in `follow_update'
    
    PokemonFollow:1551:in `update'

    I can make this work if I
     

    Attachments

    • [PokeCommunity.com] Giving the player a random pokemon with random level
      event1.PNG
      27.6 KB · Views: 16
    Hello, Essentials/RPG maker xp noob here,
    How can i use the pbAddPokemon function by passing variables through it?
    For example, you would usually do
    Code:
    pbAddPokemon(:PIKACHU,20)
    But what if i want to do something like this ?
    Code:
    pbAddPokemon(:$game_variables[27],20)
    where $game_variables[27] contains the string "PIKACHU"
    The game keeps crashing when I try this, however it doesn't seem to mind however getting an Integer variable for the level argument
    Code:
    pbAddPokemon(:PIKACHU,$game_variables[26])
     
    Back
    Top