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

[Error] Trainer Card does not work [V.18.1]

  • 80
    Posts
    6
    Years
    • Seen Nov 5, 2023
    So... when I try to open my trainer card when I have a badge this error appears:

    Code:
    ---------------------------
    Pokemon Brilliant Red
    ---------------------------
    [Pokémon Essentials version 18.1]
    
    Exception: NameError
    
    Message: undefined local variable or method `badges' for #<PokemonTrainerCard_Scene:0xe6b7ac0>
    
    
    
    Backtrace:
    
    PScreen_TrainerCard:71:in `pbDrawTrainerCardFront'
    
    PScreen_TrainerCard:69:in `each'
    
    PScreen_TrainerCard:69:in `pbDrawTrainerCardFront'
    
    PScreen_TrainerCard:30:in `pbStartScene'
    
    PScreen_TrainerCard:106:in `pbStartScreen'
    
    PScreen_PauseMenu:210:in `pbStartPokemonMenu'
    
    PScreen_PauseMenu:207:in `pbFadeOutIn'
    
    PScreen_PauseMenu:212:in `pbStartPokemonMenu'
    
    PScreen_PauseMenu:144:in `loop'
    
    PScreen_PauseMenu:274:in `pbStartPokemonMenu'
    
    
    
    This exception was logged in 
    
    C:\USERNAMEs\User\Saved Games\Pokemon Brilliant Red\errorlog.txt.
    
    Press Ctrl+C to copy this message to the clipboard.
    ---------------------------
    OK   
    ---------------------------

    Can please someone tell me how to fix it?

    One thing I can say is that I got badge 17 although as I started the game I only had two regions. That is the only clue I got
     
    Last edited:
    So... when I try to open my trainer card when I have a badge this error appears:
    <ERROR>

    Can please someone tell me how to fix it?

    One thing I can say is that I got badge 17 although as I started the game I only had two regions. That is the only clue I got

    Can you post the code of the function:
    Code:
      def pbDrawTrainerCardFront
    ?
    I believe your error is solved in the Gen 8 project (the version that I use).
     
    Can you post the code of the function:
    Code:
      def pbDrawTrainerCardFront
    ?
    I believe your error is solved in the Gen 8 project (the version that I use).

    Code:
     def pbDrawTrainerCardFront
        overlay = @sprites["overlay"].bitmap
        overlay.clear
        baseColor   = Color.new(72,72,72)
        shadowColor = Color.new(160,160,160)
        totalsec = Graphics.frame_count / Graphics.frame_rate
        hour = totalsec / 60 / 60
        min = totalsec / 60 % 60
        time = (hour>0) ? _INTL("{1}h {2}m",hour,min) : _INTL("{1}m",min)
        $PokemonGlobal.startTime = pbGetTimeNow if !$PokemonGlobal.startTime
        starttime = _INTL("{1} {2}, {3}",
           pbGetAbbrevMonthName($PokemonGlobal.startTime.mon),
           $PokemonGlobal.startTime.day,
           $PokemonGlobal.startTime.year)
        textPositions = [
           [_INTL("Name"),34,64,0,baseColor,shadowColor],
           [$Trainer.name,302,64,1,baseColor,shadowColor],
           [_INTL("ID No."),332,64,0,baseColor,shadowColor],
           [sprintf("%05d",$Trainer.publicID($Trainer.id)),468,64,1,baseColor,shadowColor],
           [_INTL("Money"),34,112,0,baseColor,shadowColor],
           [_INTL("${1}",$Trainer.money.to_s_formatted),302,112,1,baseColor,shadowColor],
           [_INTL("Pokédex"),34,160,0,baseColor,shadowColor],
           [sprintf("%d/%d",$Trainer.pokedexOwned,$Trainer.pokedexSeen),302,160,1,baseColor,shadowColor],
           [_INTL("Time"),34,208,0,baseColor,shadowColor],
           [time,302,208,1,baseColor,shadowColor],
           [_INTL("Started"),34,256,0,baseColor,shadowColor],
           [starttime,302,256,1,baseColor,shadowColor]
        ]
        pbDrawTextPositions(overlay,textPositions)
        x = 72
        region = pbGetCurrentRegion(0) # Get the current region
        imagePositions = []
        for i in 0...8
          if $Trainer.badges[i+region*8]
            imagePositions.push(["Graphics/Pictures/Trainer Card/icon_badges",x,310,i*32,badges*32,32,32])
          end
          x += 48
        end
        pbDrawImagePositions(overlay,imagePositions)
      end

    Here it is!
     
    The line:
    Code:
            imagePositions.push(["Graphics/Pictures/Trainer Card/icon_badges",x,310,i*32,badges*32,32,32])
    should be recplaced with:
    Code:
            imagePositions.push(["Graphics/Pictures/Trainer Card/icon_badges",x,310,i*32,region*32,32,32])
    (The error was around the end of the line, "badges" is replaced with "region").
     
    The line:
    Code:
            imagePositions.push(["Graphics/Pictures/Trainer Card/icon_badges",x,310,i*32,badges*32,32,32])
    should be recplaced with:
    Code:
            imagePositions.push(["Graphics/Pictures/Trainer Card/icon_badges",x,310,i*32,region*32,32,32])
    (The error was around the end of the line, "badges" is replaced with "region").

    Thanks man, it works now!
     
    Back
    Top