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

NPC meant to check the type of your pokemon causes crash

429
Posts
4
Years
  • [Pokémon Essentials version 19.1]
    [Generation 8 Project v1.1.0]
    [v19.1 Hotfixes 1.0.7]

    Exception: RuntimeError
    Message: Script error in event 58 (coords 2,3), map 4 (Pokémon Lab):
    Exception: SyntaxError
    Message: (eval):1: syntax error, unexpected '|', expecting ')'
    pbChoosePokemon(1, 3, proc( |pkmn|
    ^
    (eval):6: syntax error, unexpected ')', expecting end-of-input

    ***Full script:
    pbChoosePokemon(1, 3, proc( |pkmn|
    isConst?(pkmn.type1,PBTypes,
    :FIGHTING) ||
    isConst?(pkmn.type2,PBTypes,
    :FIGHTING)
    )


    Backtrace:


    Backtrace:
    033:Interpreter:189:in `rescue in execute_script'
    033:Interpreter:135:in `execute_script'
    034:Interpreter_Commands:1030:in `command_355'
    034:Interpreter_Commands:116:in `execute_command'
    033:Interpreter:127:in `block in update'
    033:Interpreter:87:in `loop'
    033:Interpreter:87:in `update'
    032:Scene_Map:157:in `block in update'
    032:Scene_Map:155:in `loop'
    032:Scene_Map:155:in `update'


    Tried replacing ) with }s and }s with )s. How do I actually fix this? This NPC is supposed to let you select a Pokemon in your party, check whether it is or isn't Fighting type, and then say "Correct!" or "Incorrect!" depending on whether you showed the NPC a fighting type or not.

    There's going to be more to this NPC in the final release but for the script I have in mind to work, I need to be able to check the player's chosen Pokemon type.
     
    Last edited:
    124
    Posts
    3
    Years
  • The proc bit needs to be surrounded by curly brackets - { and } - and you're missing one closing bracket. Even with those changes, I don't think PBTypes exists in v19+. You could try this:
    Code:
    pbChoosePokemon(1, 3,
      proc { |pkmn|
        pkmn.hasType?(:FIGHTING)
      }
    )
     
    429
    Posts
    4
    Years
  • Thank you, this works perfectly.

    How do I "get" the Pokemon selected by the player as a target for Pokemon-editing scripts, such as teaching him a specific move?

    If that's not possible and this coding language can only select Pokemon via their position in the party, how do I make the NPC check whether the first Pokemon in the player's party is Fighting-type or not?
     
    Last edited:
    124
    Posts
    3
    Years
  • Thank you, this works perfectly.

    How do I "get" the Pokemon selected by the player as a target for Pokemon-editing scripts, such as teaching him a specific move?

    If that's not possible and this coding language can only select Pokemon via their position in the party, how do I make the NPC check whether the first Pokemon in the player's party is Fighting-type or not?

    When you do pbChoosePokemon, the first argument is the game variable the selected Pokémon's data is saved to, in this case we used game variable 1. You can retrieve the Pokémon we selected and have it learn a move like this:
    Code:
    pkmn = pbGetPokemon(1)
    pkmn.learn_move(:THUNDER)
    This has the selected Pokémon silently learn Thunder, replacing the first move if it knows more than four moves.
    If you want the player to be able to choose which move to replace, that's the same as a move tutor. There's an example NPC for that in Cedolan City > Cedolan City Condo > NPC on the left.
    If you want a specific move to be replaced like when Rotom swaps forms, then you have an example of that as well.
     
    429
    Posts
    4
    Years
  • That's what I was using, but it's not working. Is it possible that the \ch[1,-1,Choice 1,Choice 2,Choice 3] code I'm using right after the Pokemon selection is overwriting the selected Pokemon variable?

    EDIT: Yep, that was the problem. I fixed it by changing the 1 to 69 and renaming that to "BakupUnusedVariable".

    pbChoosePokemon(69, 3,
    proc { |pkmn|
    pkmn.hasType?(:FIGHTING)
    }
    )
    pkmn = pbGetPokemon(69)
    pkmn.learn_move(:THUNDER)

    Now I just need to do it for every move and then I'll upload the NPC script.
     
    Last edited:
    Back
    Top