How to change the Trainer Card depending on a variable

Krahssen

Novice
Member
Joined
May 31, 2018
Posts
31
Hi!
I have a question about the Trainer Card.
How can I change the background and graphics of my trainer card depending on a variable of three options in an event?

For example: If I choose Bulbasaur, my Trainer Card base changes to a green, if I choose Squirtle to a blue one, etc

Sorry for my english.
Thank you!
 

Jonas930

Is anyonre there?
Member
Joined
Apr 15, 2017
Posts
102
make three three different background, and change this to
if $Trainer.isFemale? && background
addBackgroundPlane(@sprites,"bg","Trainer Card/bg_f",@viewport)
else
addBackgroundPlane(@sprites,"bg","Trainer Card/bg",@viewport)
end

something looks like this

if $game_variables[VARIABLES ID GOES HERE]==1
addBackgroundPlane(@sprites,"bg","Trainer Card/bg_green",@viewport)
elsif $game_variables[VARIABLES ID GOES HERE]==2
addBackgroundPlane(@sprites,"bg","Trainer Card/bg_red",@viewport)
else
addBackgroundPlane(@sprites,"bg","Trainer Card/bg_blue",@viewport)
end

Those are just examples. You have to set it up properly.
 

Krahssen

Novice
Member
Joined
May 31, 2018
Posts
31
I tried that, but it didn't work.
I named the graphics "bg_green", "bg_blue" and "bg_red", as in the examples, but the Trainer Card doesn't change when the variable is activated.

Here is the code as I have it:


Code:
class PokemonTrainerCard_Scene
  def pbUpdate
    pbUpdateSpriteHash(@sprites)
  end

  def pbStartScene
    @viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
    @viewport.z = 99999
    @sprites = {}
    background = pbResolveBitmap(sprintf("Graphics/Pictures/Trainer Card/bg_f"))
    if $game_variables[0026]==1
    addBackgroundPlane(@sprites,"bg","Trainer Card/bg_green",@viewport)
    elsif $game_variables[0026]==2
    addBackgroundPlane(@sprites,"bg","Trainer Card/bg_red",@viewport)
    else
    addBackgroundPlane(@sprites,"bg","Trainer Card/bg_blue",@viewport)
    end
    cardexists = pbResolveBitmap(sprintf("Graphics/Pictures/Trainer Card/card_f"))
    @sprites["card"] = IconSprite.new(0,0,@viewport)
    if $Trainer.isFemale? && cardexists
      @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card_f")
    else
      @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card")
    end
    @sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
    pbSetSystemFont(@sprites["overlay"].bitmap)
    @sprites["trainer"] = IconSprite.new(336,112,@viewport)
    @sprites["trainer"].setBitmap(pbPlayerSpriteFile($Trainer.trainertype))
    @sprites["trainer"].x -= (@sprites["trainer"].bitmap.width-128)/2
    @sprites["trainer"].y -= (@sprites["trainer"].bitmap.height-128)
    @sprites["trainer"].z = 2
    pbDrawTrainerCardFront
    if $PokemonGlobal.trainerRecording
      $PokemonGlobal.trainerRecording.play
    end
    pbFadeInAndShow(@sprites) { pbUpdate }
  end

  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 = _ISPRINTF("{1:02d}:{2:02d}",hour,min)
    $PokemonGlobal.startTime = pbGetTimeNow if !$PokemonGlobal.startTime
    starttime = _INTL("{1} {2}, {3}",
       pbGetAbbrevMonthName($PokemonGlobal.startTime.mon),
       $PokemonGlobal.startTime.day,
       $PokemonGlobal.startTime.year)
    textPositions = [
       [_INTL("Nombre"),34,64,0,baseColor,shadowColor],
       [$Trainer.name,302,64,1,baseColor,shadowColor],
       [_INTL("Nº ID"),332,64,0,baseColor,shadowColor],
       [sprintf("%05d",$Trainer.publicID($Trainer.id)),468,64,1,baseColor,shadowColor],
       [_INTL("Dinero"),34,112,0,baseColor,shadowColor],
       [_INTL("${1}",pbCommaNumber($Trainer.money)),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("Tiempo jugado"),34,208,0,baseColor,shadowColor],
       [time,302,208,1,baseColor,shadowColor],
       [_INTL("Inició"),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,region*32,32,32])
      end
      x += 48
    end
    pbDrawImagePositions(overlay,imagePositions)
  end

  def pbTrainerCard
    loop do
      Graphics.update
      Input.update
      pbUpdate
      if Input.trigger?(Input::B)
        break
      end
    end
  end

  def pbEndScene
    pbFadeOutAndHide(@sprites) { pbUpdate }
    pbDisposeSpriteHash(@sprites)
    @viewport.dispose
  end
end



class PokemonTrainerCardScreen
  def initialize(scene)
    @scene = scene
  end

  def pbStartScreen
    @scene.pbStartScene
    @scene.pbTrainerCard
    @scene.pbEndScene
  end
end
 

leilou

A wild Minun appeared!
Member
Joined
May 17, 2017
Posts
223
in that case you gotta alter that passage:
Code:
@sprites["card"] = IconSprite.new(0,0,@viewport)
if $Trainer.isFemale? && cardexists
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card_f")
else
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card")
end
 

Krahssen

Novice
Member
Joined
May 31, 2018
Posts
31
in that case you gotta alter that passage:
Code:
@sprites["card"] = IconSprite.new(0,0,@viewport)
if $Trainer.isFemale? && cardexists
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card_f")
else
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card")
end
Oh, thank you
Something like this?:
Code:
@sprites["card"] = IconSprite.new(0,0,@viewport)
if $game_variables[0026]==1
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card_green")
elsif $game_variables[0026]==2
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card_blue")
else
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card_red")
end

EDIT: By writting the code in that way, my character always starts with the "card_red" and at the end of the event with the variables he keep maintaining the "red card" regardless of the option chosen. (Sorry if I expressed myself badly in English)

EDIT 2: I solved it, the problem was the "00" of the variable.
The final code was:

Code:
@sprites["card"] = IconSprite.new(0,0,@viewport)
if $game_variables[26]==1
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card_green")
elsif $game_variables[26]==2
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card_blue")
elsif $game_variables[26]==3
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card_red")
else
  @sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card")
end
 
Last edited:
Top