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

Script: [v13+] Character Selection

FL

Pokémon Island Creator
2,452
Posts
13
Years
    • Seen yesterday
    I have an error with this script :(

    Spoiler:
    The script is currently installed (at a script section above main)? You are using an older method from an old Character Selection version. If you have the Character Selection v1.1 you need to call a different method like in the example.
     
    7
    Posts
    1
    Years
    • Seen Oct 23, 2022
    Partner, I try to use this code

    overworld = ["trchar000","trchar001","trchar002","trchar003"]
    battle = ["trainer000","trainer001","trainer002","trainer003"]
    result = pbCharacterSelection(overworld,battle)
    if result==0
    pbRegisterPartner(PBTrainers::HOOPYTRAINER,"Zaphod",0)
    elsif result==1
    pbRegisterPartner(PBTrainers::OTHERTRAINER,"Purple",0)
    elsif result==2
    pbRegisterPartner(PBTrainers::ANOTHERTRAINER,"Gray",0)
    elsif result==3
    pbRegisterPartner(PBTrainers::ONEMORETRAINER,"Brown",0)
    end

    , and I get this error.

    [2022-10-18 23:25:40 +0200]
    [Pokémon Essentials version 20.1]

    Script error in event 2 (coords 0,14), map 1 (Intro)
    Exception: NameError
    Message: uninitialized constant Interpreter::PBTrainers

    ***Full script:
    overworld = ["trainer_POKEMONTRAINER_Red", "trainerPAU_2", "trainer_POKEMONTRAINER_Brendan",
    "trainer_POKEMONTRAINER_May"]
    battle = ["POKEMONTRAINER_Red", "trainerPAU_1", "POKEMONTRAINER_Brendan", "POKEMONTRAINER_May"]
    result = startCharacterSelection(overworld,battle)
    pbChangePlayer(result+1)
    insertSomeMethodNameHere = result
    if insertSomeMethodNameHere==0
    pbRegisterPartner(PBTrainers::HOOPYTRAINER,"Zaphod",0)
    elsif insertSomeMethodNameHere==1
    pbRegisterPartner(PBTrainers::OTHERTRAINER,"Purple",0)
    elsif insertSomeMethodNameHere==2
    pbRegisterPartner(PBTrainers::ANOTHERTRAINER,"Gray",0)
    elsif insertSomeMethodNameHere==3
    pbRegisterPartner(PBTrainers::ONEMORETRAINER,"Brown",0)
    end

    Backtrace:
    (eval):10:in `execute_script'
    033:Interpreter:143:in `eval'
    033:Interpreter:143:in `execute_script'
    034:Interpreter_Commands:1112:in `command_355'
    034:Interpreter_Commands:116:in `execute_command'
    033:Interpreter:133:in `block in update'
    033:Interpreter:90:in `loop'
    033:Interpreter:90:in `update'
    032:Scene_Map:160:in `block in update'
    032:Scene_Map:159:in `loop'

    It is clear that the PBTrainer constant fails, but I don't know which one I should use to define the character of my partner.
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    Sorry, the problem was the version of Pokemon Essentials
    Remember that this script works with several Essentials Versions, even v13.

    Partner, I try to use this code

    Code:
    overworld = ["trchar000","trchar001","trchar002","trchar003"]
    battle = ["trainer000","trainer001","trainer002","trainer003"]
    result = pbCharacterSelection(overworld,battle) 
    if result==0
      pbRegisterPartner(PBTrainers::HOOPYTRAINER,"Zaphod",0)
    elsif result==1
      pbRegisterPartner(PBTrainers::OTHERTRAINER,"Purple",0)
    elsif result==2
      pbRegisterPartner(PBTrainers::ANOTHERTRAINER,"Gray",0)
    elsif result==3
      pbRegisterPartner(PBTrainers::ONEMORETRAINER,"Brown",0)
    end

    , and I get this error.

    Spoiler:


    It is clear that the PBTrainer constant fails, but I don't know which one I should use to define the character of my partner.
    Wow, the error changed your code from "trchar000" to "trainer_POKEMONTRAINER_Red" XD

    PBTrainer doesn't work this way for Essentials v19 and newer.

    Instead, look at the docs how to make a partner trainer. The new code is like your method, but remove 'PBTrainer'.

    Code:
    if result==0
      pbRegisterPartner(:HOOPYTRAINER,"Zaphod",0)
    elsif result==1
      pbRegisterPartner(:OTHERTRAINER,"Purple",0)
    elsif result==2
      pbRegisterPartner(:ANOTHERTRAINER,"Gray",0)
    elsif result==3
      pbRegisterPartner(:ONEMORETRAINER,"Brown",0)
    end
     
    7
    Posts
    1
    Years
    • Seen Oct 23, 2022
    Thanks FL,

    Another thing FL, you know how to use Conditional Branches with Scripts. I am trying to make depending on the player you choose to give one value or another to a variable.

    I have done this, but it doesn't work.

    if (result == 0)
    $gameVariables.value(26) = 0

    end
    if (result == 1)
    $gameVariables.value(26) = 1

    end
    if (result == 2)
    $gameVariables.value(26) = 2

    end

    Sorry if I'm asking you a lot, but I'm very excited to get into the world of pokemon fangames and you're helping me a lot. In addition, it is my first year in the computer engineering career and at the moment what little I know about C++ and it is not 100% the same as in RPGMaker.
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    Thanks FL,

    Another thing FL, you know how to use Conditional Branches with Scripts. I am trying to make depending on the player you choose to give one value or another to a variable.

    I have done this, but it doesn't work.
    Code:
    if (result == 0)
    $gameVariables.value(26) = 0
    
    end
    if (result == 1)
    $gameVariables.value(26) = 1
    
    end
    if (result == 2)
    $gameVariables.value(26) = 2
    
    end

    Sorry if I'm asking you a lot, but I'm very excited to get into the world of pokemon fangames and you're helping me a lot. In addition, it is my first year in the computer engineering career and at the moment what little I know about C++ and it is not 100% the same as in RPGMaker.
    Instead of '$gameVariables.value(26)' use '$game_variables[26]'. You can see the syntax if you look at the example events or even script. By the way, this was probably an example, but can also put directly '$gameVariables.value(26) = result'

    For these questions less related with this script, let's continue at another thread. And please use the code tag when posting code.
     
    2
    Posts
    1
    Years
    • Seen Oct 28, 2022
    Hello, I have pokemon essential v16.3 and I can't get it to work.

    ---------------------------
    Pokemon Essentials Esp v16.3
    ---------------------------
    Exception: RuntimeError

    Message: Script error within event 2, map 1 (Enter):

    Exception: ArgumentError

    Message: (eval):3:in `startCharacterSelection'wrong number of arguments(0 for 2)

    ***Fullscript:

    overworld = ["trchar000", "trchar001"]
    battle = ["trainer000", "trainer001"]
    result = startCharacterSelection
    '(overworld, battle)'
    pbChangePlayer(result+1)


    Interpreter:243:in `pbExecuteScript'

    (eval):3:in `pbExecuteScript'

    Interpreter:1606:in `eval'

    Interpreter:243: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:103:in `update'



    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:103:in `update'

    Scene_Map:101:in `loop'

    Scene_Map:114:in `update'

    Scene_Map:68:in `main'


    (Thanks for the help).
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    Hello, I have pokemon essential v16.3 and I can't get it to work.

    Spoiler:



    (Thanks for the help).
    Your error means that a method with 2 arguments is called without these arguments. Looking at your code, I see that you break the line before the '(' on the method. This doesn't work on ruby. So you need to use something like:
    Code:
    overworld = ["trchar000", "trchar001"]
    battle = ["trainer000", "trainer001"]
    result = startCharacterSelection(
    overworld, battle)
    pbChangePlayer(result+1)
     
    2
    Posts
    1
    Years
    • Seen Oct 28, 2022
    the mini spriters appear when selecting a character, but when selecting one of them the image disappears.
    fallo.png

    And when choosing a name the mini sprite also always changes to the same.
    fallo 2.png

    overworld = ["trchar000", "trchar001"]
    battle = ["trainer000", "trainer001"]
    result = startCharacterSelection(
    overworld, battle)
    pbChangePlayer(result+1)

    sorry for my stupidity.
     
    Last edited:

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    the mini spriters appear when selecting a character, but when selecting one of them the image disappears.
    Spoiler:
    You removed the "Show Picture" command from intro event. You need to add it back based on this script result. You can also use '$Trainer.id' to check the selected player on a Conditional Branch.
     
    9
    Posts
    3
    Years
    • Seen Apr 4, 2023
    I managed to get it to work but now it crashes out of the character selection screen due to issues with some of my character sprites? :(

    ===================================================

    [Pokémon Essentials version 20.1]
    [v20.1 Hotfixes 1.0.7]

    Script error in event 1 (coords 0,0), map 1 (Intro)
    Exception: NoMethodError
    Message: undefined method `width' for nil:NilClass

    ***Full script:
    overworld =
    ["trainer_POKEMONTRAINER_Red","trainer_POKEMONTRAINER_Leaf","trainer_POKEMONTRAINER_Brendan","trainer_POKEMONTRAI
    NER_May","trainer_POKEMONTRAINER_Ethan","trainer_POKEMONTRAINER_Lyra"]
    battle =
    ["POKEMONTRAINER_Red","POKEMONTRAINER_Leaf","POKEMONTRAINER_Brendan","POKEMONTRAINER_May","POKEMONTRAINER
    _Ethan","POKEMONTRAINER_Lyra"]
    result = startCharacterSelection(overworld,battle)
    pbChangePlayer(result+1)

    Backtrace:
    386:Character Selection:65:in `updateCursor'
    386:Character Selection:96:in `block in pbMidScene'
    386:Character Selection:77:in `loop'
    386:Character Selection:77:in `pbMidScene'
    386:Character Selection:233:in `pbStartScreen'
    386:Character Selection:244:in `block in startCharacterSelection'
    082:MessageConfig:570:in `pbFadeOutIn'
    386:Character Selection:241:in `startCharacterSelection'
    (eval):7:in `execute_script'
    033:Interpreter:143:in `eval'

    ====================================================

    Anyone able to help me out here? Would be much appreciated :)
     
    Last edited:

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    I managed to get it to work but now it crashes out of the character selection screen due to issues with some of my character sprites? :(

    Spoiler:


    Anyone able to help me out here? Would be much appreciated :)
    Looks like the game can't find a battle trainer sprite. Recheck if your sprite names match with the sprites on "Graphics/Pictures/Trainers" folder.
     
    9
    Posts
    3
    Years
    • Seen Apr 4, 2023
    Looks like the game can't find a battle trainer sprite. Recheck if your sprite names match with the sprites on "Graphics/Pictures/Trainers" folder.

    Hmm I've checked and everything should work fine - everything should be in the right place and with the correct naming.

    Here's the output window text if that helps at all:

    ======================================================================


    Exception `Errno::EINVAL' at 019:FileTests:126 - Invalid argument @ rb_sysopen - Graphics/Characters/trainer_POKEMONTRAI
    NER_May.png
    Exception `Errno::EINVAL' at 019:FileTests:126 - Invalid argument @ rb_sysopen - Graphics/Characters/trainer_POKEMONTRAI
    NER_May.gif
    Exception `Errno::ENOENT' at 081:RPG_Cache:118 - No such file or directory - Graphics/Characters/trainer_POKEMONTRAI
    NER_May
    Exception `Errno::EINVAL' at 019:FileTests:126 - Invalid argument @ rb_sysopen - Graphics/Trainers/POKEMONTRAINER
    _Ethan.png
    Exception `Errno::EINVAL' at 019:FileTests:126 - Invalid argument @ rb_sysopen - Graphics/Trainers/POKEMONTRAINER
    _Ethan.gif
    Exception `Errno::EINVAL' at 019:FileTests:126 - Invalid argument @ rb_sysopen - Graphics/Characters/POKEMONTRAINER
    _Ethan.png
    Exception `Errno::EINVAL' at 019:FileTests:126 - Invalid argument @ rb_sysopen - Graphics/Characters/POKEMONTRAINER
    _Ethan.gif
    Exception `NoMethodError' at 386:Character Selection:65 - undefined method `width' for nil:NilClass
    Exception `EventScriptError' at 033:Interpreter:182 - EventScriptError

    =======================================================================

    Cheers if you can figure it out - it only actually crashes if I try and select Ethan, otherwise even if I select May it seems to at least run fine.
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    Hmm I've checked and everything should work fine - everything should be in the right place and with the correct naming.

    Here's the output window text if that helps at all:

    ======================================================================


    Spoiler:


    =======================================================================

    Cheers if you can figure it out - it only actually crashes if I try and select Ethan, otherwise even if I select May it seems to at least run fine.
    Looks like Ethan trainer file is wrong. I guess that you aren't breaking line in the right places. You can't break strings like

    Code:
    "POKEMONTRAINER_Ethan"´
    Into
    Code:
    "POKEMONTRAINER
    _Ethan"´

    To solve this, change the code to
    Code:
    overworld =
    ["trainer_POKEMONTRAINER_Red","trainer_POKEMONTRAINER_Leaf","trainer_POKEMONTRAINER_Brendan",
    "trainer_POKEMONTRAINER_May","trainer_POKEMONTRAINER_Ethan","trainer_POKEMONTRAINER_Lyra"]
    battle =
    ["POKEMONTRAINER_Red","POKEMONTRAINER_Leaf","POKEMONTRAINER_Brendan","POKEMONTRAINER_May",
    "POKEMONTRAINER_Ethan","POKEMONTRAINER_Lyra"]
    result = startCharacterSelection(overworld,battle)
    pbChangePlayer(result+1)
    Or put the below code above main:
    Code:
    def selectTrainer
      overworld =
      ["trainer_POKEMONTRAINER_Red", "trainer_POKEMONTRAINER_Leaf", "trainer_POKEMONTRAINER_Brendan", "trainer_POKEMONTRAINER_May", "trainer_POKEMONTRAINER_Ethan", "trainer_POKEMONTRAINER_Lyra"]
      battle =
      ["POKEMONTRAINER_Red", "POKEMONTRAINER_Leaf", "POKEMONTRAINER_Brendan","POKEMONTRAINER_May", "POKEMONTRAINER_Ethan", "POKEMONTRAINER_Lyra"]
      result = startCharacterSelection(overworld,battle)
      pbChangePlayer(result+1)
    end
    And call 'selectTrainer' as script command.
     
    9
    Posts
    3
    Years
    • Seen Apr 4, 2023
    To solve this, change the code to
    Code:
    overworld =
    ["trainer_POKEMONTRAINER_Red","trainer_POKEMONTRAINER_Leaf","trainer_POKEMONTRAINER_Brendan",
    "trainer_POKEMONTRAINER_May","trainer_POKEMONTRAINER_Ethan","trainer_POKEMONTRAINER_Lyra"]
    battle =
    ["POKEMONTRAINER_Red","POKEMONTRAINER_Leaf","POKEMONTRAINER_Brendan","POKEMONTRAINER_May",
    "POKEMONTRAINER_Ethan","POKEMONTRAINER_Lyra"]
    result = startCharacterSelection(overworld,battle)
    pbChangePlayer(result+1)

    Amazing, this worked a treat! The trainer sprite then doesn't show up after for when Oak asks about the player name, but rn I'm just so happy it's working.
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    The trainer sprite then doesn't show up after for when Oak asks about the player name
    This is strange. Did you correctly configured the metadata with the characters graphics?
     
    2
    Posts
    4
    Years
    • Seen Sep 23, 2023
    Hi. Im using this script on v20.1 and ive noticed that after selecting a player character the graphics and chosen player change after the script is finished and you enter naming the player.

    I know im probably being stupid but ive tried fixing it with no solutions so any help would be great
     

    FL

    Pokémon Island Creator
    2,452
    Posts
    13
    Years
    • Seen yesterday
    Hi. Im using this script on v20.1 and ive noticed that after selecting a player character the graphics and chosen player change after the script is finished and you enter naming the player.

    I know im probably being stupid but ive tried fixing it with no solutions so any help would be great
    Graphics between the code and the PBS should match, so change the example OR the data at metadata.txt
     
    Back
    Top