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

[Scripting Question] Trainer card badges

49
Posts
8
Years
  • Age 36
  • Seen Jan 17, 2017
I need help on my trainer card, I want my card to have 24 bagdes of 3 region, 8 of each. I have an example of how I want it. I do not understand script. thank you
 

Attachments

  • sprites_trainer_ash_ketchum_satoshi_pokemon_anime__by_kensuyjin33-d7jw5x9.png
    sprites_trainer_ash_ketchum_satoshi_pokemon_anime__by_kensuyjin33-d7jw5x9.png
    72.5 KB · Views: 265
Last edited by a moderator:
1,680
Posts
8
Years
  • Age 24
  • Seen today
This was so much harder because I don't know what your final trainer card will look like, so either post that up too and I'll edit the script or you edit it yourself when you have the graphics.
Line 67, PScreen_TrainerCard. Change
Code:
    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/badges",x,310,i*32,region*32,32,32])
      end
      x+=48
    end
to
Code:
    x=72 # change to x coordinate of left most badge slot
    y=250 # change to y coordinate of top most badge slot
    imagePositions=[]
    for i in 0...3 #change 3 to total number of regions
      for j in 0...8
        if $Trainer.badges[j+i*8]
          imagePositions.push(["Graphics/Pictures/badges",x,y,j*32,i*32,32,32])
        end
        x+=48 # Change to the distance between the top left corners of two badge slots beside each other
      end
      x=72
      y+=40 # Change to the distance between the top left corners of two badge slots on top of each other
    end
Final result
oVs3TIC.png
 
49
Posts
8
Years
  • Age 36
  • Seen Jan 17, 2017
My card will have 512 x 452.
He will definitely stay.
 

Attachments

  • trainercardf.PNG
    trainercardf.PNG
    11.4 KB · Views: 163
1,680
Posts
8
Years
  • Age 24
  • Seen today
Your image is bigger than the screen then, but that's not my issue.
This should work, based off your image, but I'm not at my computer, so I don't know for a fact.

Vendily, you were right, my image was great, I slowed down, it's almost perfect.View attachment 80664
It won't look perfect because you don't have a perfect 2x size, and the space between rows is different. (39 px for the top two and 37 px for the bottom two.)
Code:
    x=72 # x coordinate of left most badge slot
    y=243 # y coordinate of top most badge slot
    imagePositions=[]
    for i in 0...3 #change 3 to total number of regions
      for j in 0...8
        if $Trainer.badges[j+i*8]
          imagePositions.push(["Graphics/Pictures/badges",x,y,j*32,i*32,32,32])
        end
        x+=48 # distance between the top left corners of two badge slots beside each other
      end
      x=72
      y+=38 # distance between the top left corners of two badge slots on top of each other
    end
 
Last edited:
49
Posts
8
Years
  • Age 36
  • Seen Jan 17, 2017
Sem título.pngThe words on the card are getting like this, how do I make it perfect? The size of the card is now correct right?
 
1,680
Posts
8
Years
  • Age 24
  • Seen today
Line 52 section PScreen_TrainerCard
change this:
Code:
    textPositions=[
       [_INTL("Name"),34,64,0,baseColor,shadowColor],
       [_INTL("{1}",$Trainer.name),302,64,1,baseColor,shadowColor],
       [_INTL("ID No."),332,64,0,baseColor,shadowColor],
       [_INTL("{1}",pubid),468,64,1,baseColor,shadowColor],
       [_INTL("Money"),34,112,0,baseColor,shadowColor],
       [_INTL("${1}",$Trainer.money),302,112,1,baseColor,shadowColor],
       [_INTL("Pokédex"),34,160,0,baseColor,shadowColor],
       [_ISPRINTF("{1:d}/{2: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]
    ]
to this
Code:
textPositions=[
       [_INTL("Name"),34,51,0,baseColor,shadowColor],
       [_INTL("{1}",$Trainer.name),302,51,1,baseColor,shadowColor],
       [_INTL("ID No."),332,51,0,baseColor,shadowColor],
       [_INTL("{1}",pubid),468,51,1,baseColor,shadowColor],
       [_INTL("Money"),34,98,0,baseColor,shadowColor],
       [_INTL("${1}",$Trainer.money),302,98,1,baseColor,shadowColor],
       [_INTL("Pokédex"),34,148,0,baseColor,shadowColor],
       [_ISPRINTF("{1:d}/{2:d}",$Trainer.pokedexOwned,$Trainer.pokedexSeen),302,148,1,baseColor,shadowColor],
       [_INTL("Time"),34,194,0,baseColor,shadowColor],
       [time,302,194,1,baseColor,shadowColor],
    ]
line 24, change:
Code:
    @sprites["trainer"]=IconSprite.new(336,112,@viewport)
to:
Code:
    @sprites["trainer"]=IconSprite.new(336,98,@viewport)


If you cant read the black text (I barely can), go to line 50 and change
Code:
    baseColor=Color.new(72,72,72)
    shadowColor=Color.new(160,160,160)
to:
Code:
    baseColor=Color.new(248,248,248)
    shadowColor=Color.new(72,80,88)
Play with the colours till you get a pair you like.

images
 
1,680
Posts
8
Years
  • Age 24
  • Seen today
View attachment 80685Vendily, When I put the 24 bagdes, it was like this.

You need to use the badge code I posted earlier. Around line 67.
Code:
    x=72 # x coordinate of left most badge slot
    y=243 # y coordinate of top most badge slot
    imagePositions=[]
    for i in 0...3 #change 3 to total number of regions
      for j in 0...8
        if $Trainer.badges[j+i*8]
          imagePositions.push(["Graphics/Pictures/badges",x,y,j*32,i*32,32,32])
        end
        x+=48 # distance between the top left corners of two badge slots beside each other
      end
      x=72
      y+=38 # distance between the top left corners of two badge slots on top of each other
    end
I assumed you still had it.
 
49
Posts
8
Years
  • Age 36
  • Seen Jan 17, 2017
There is a problem, after I put this script on line 67, it is giving this error.imagem.png I do not know, maybe it was because of this being in the previous image script to be bigger? And the script is no longer on line 67, that's on line 65, that changed after you've placed the last one. What can I do?imagem2.png

Vendily Complicating me a bit, here are some pictures of my project, it becomes easier for you, and pass me the whole scripttrainercardf.PNG

badges.png
 
Last edited by a moderator:
1,680
Posts
8
Years
  • Age 24
  • Seen today
Your error means you missed an end somewhere.
To save us from further headaches, since I an certain the code is fine, take this pastebin of the entire section.
http://pastebin.com/raw/MtnFMbDT
Just replace the entire section with this, since It looks like your code is untouched other than my edits.
Looks good from my end, if that's worth anything.
p5ca0XN.png

Just check the transparency on those badges, some of those areas were supposed to be invisible, I assume.
 
11
Posts
4
Years
  • Age 33
  • Seen Apr 22, 2024
Hello Vendily,

I have been trying to something similar to this but with two rows of 9 badges. I have tried everything on here multiple times and I just can't get it to work. I'm still kind of new to the scripting so I'm not sure if I'm missing something or not. I know you probably have done this a few times and I'm sorry if this is a bother. But any help or tips you could give me would be much appreciated. Here is what I'm working with.

Very respectfully



4f3OxRR.png


V3NOfEm.png
 
Last edited:
1,680
Posts
8
Years
  • Age 24
  • Seen today
wow talk about a blast from the past.
the code just needs a few more edits
Code:
    x=72 # x coordinate of left most badge slot
    y=243 # y coordinate of top most badge slot
    imagePositions=[]
    for i in 0...3 #change 3 to total number of regions
      for j in 0...8 #change 8 number of badges in a row
        if $Trainer.badges[j+i*8] #change 8 to number of badges in a row
          imagePositions.push(["Graphics/Pictures/badges",x,y,j*32,i*32,32,32]) # These 32's are the dimensions of each badge (not sure if you changed that)
        end
        x+=48 # distance between the top left corners of two badge slots beside each other
      end
      x=72
      y+=38 # distance between the top left corners of two badge slots on top of each other
    end

Same deal in the end, just a few more edits.
 
11
Posts
4
Years
  • Age 33
  • Seen Apr 22, 2024
Thank you so much for your reply. So I try that one and nothing is showing up on the card. I believed I change the numbers that were necessary.

x=32 # x coordinate of left most badge slot
y=262 # y coordinate of top most badge slot
imagePositions=[]
for i in 0...2 #change 3 to total number of regions
for j in 0...9 #change 8 number of badges in a row
if $Trainer.badges[j+i*8] #change 8 to number of badges in a row
imagePositions.push(["Graphics/Pictures/badges",x,y,j*32,i*32,32,32]) # These 32's are the dimensions of each badge (not sure if you changed that)
end
x+=48 # distance between the top left corners of two badge slots beside each other
end
x=32
y+=38 # distance between the top left corners of two badge slots on top of each other
end
I think this is what is supposed to be but not sure.
 
1,680
Posts
8
Years
  • Age 24
  • Seen today
you didn't change the second 8 to 9.
did you debug yourself the badges? gotta have em to see em.
 
11
Posts
4
Years
  • Age 33
  • Seen Apr 22, 2024
Yeah, I did that, sorry I sent this one after I was trying to play around with it. But yeah I went through it again just to make sure I didn't make the mistake and yes I debug all the badges, still nothing. I can get one row of 9 badges to show up no problem. It's just adding a second row that's killing me lol.
 
2
Posts
4
Years
  • Age 25
  • Seen Jun 7, 2021
Hi! This post is absolutely gold, but I have this dilemma: I want to have 20 medals on the Trainer Card, but with this order per row ... 8, 4 and 8. Why is this order so strange? Because my fangame aims to adapt the anime of pokémon, first from Kanto to Johto, and well, the Orange Islands that are in between have only 4 medals. Vandily, could you help me please? Thanks in advance
 
1,680
Posts
8
Years
  • Age 24
  • Seen today
Hi! This post is absolutely gold, but I have this dilemma: I want to have 20 medals on the Trainer Card, but with this order per row ... 8, 4 and 8. Why is this order so strange? Because my fangame aims to adapt the anime of pokémon, first from Kanto to Johto, and well, the Orange Islands that are in between have only 4 medals. Vandily, could you help me please? Thanks in advance

Um, Do you have an example picture? Mostly because I'm not sure exactly how you want it to look, and I don't want to make a shortcut that doesn't work for you, or an edit that's unnecessary.
 
Back
Top