• 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 18 badges

iiGeorgie

Georgie
12
Posts
8
Years
Hi, I'm making a fan game and I want to have 18 badges in one region. I've looked around the essentials wiki for a way to code it so that the badges all show up on the trainer card however I've been unable to find one that has been able to help me...

my trainer card is designed so that there are two rows which have 9 badges each. Is there anyway I can set my script to have the badges in the correct places?

Thank you in advance to anyone who helps me!
 
Last edited by a moderator:

iiGeorgie

Georgie
12
Posts
8
Years
Lucky you, I've already done this before.
One thing for you though, change for j in 0...8 to for j in 0...9 since that's how many you want on a row.

Yeah I saw that post earlier but I wasn't exactly sure about it.
What would I have to put for them to work on my trainer card design? I'm not so experienced in script yet sorry ;-; Could you tell me the exact code I would need for it please?
 
1,677
Posts
8
Years
  • Age 23
  • Seen today
Okay, so this is the code from the post that does the thing, but you'll need to edit a few things.
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 (in pixels)
    y=250 # change to y coordinate of top most badge slot (in pixels)
    imagePositions=[]
    for i in 0...3 #change 3 to total number of rows
      for j in 0...9 #badges in a row
        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 (in pixels)
      end
      x=72 #make this equal to the first x=72 if you change that.
      y+=40 # Change to the distance between the top left corners of two badge slots on top of each other (in pixels)
    end
After you do these changes, you'll need to open your badges image (Graphics/Pictures/badges.png) and make it have 9 badges on each row.
That's it. If you're still stuck, attach the image you use for the trainer cards and I can set up this little segment, explaining as I go along.
EDIT: Oh, if you don't want multiple rows, and just have the specific badges change for each region, use this snippet instead.
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 (in pixels)
    y=250 # change to y coordinate of top most badge slot (in pixels)
    imagePositions=[]
    i=pbGetCurrentRegion(0) # Get the current region
    for j in 0...9 #badges in a row
      if $Trainer.badges[j+i*9] # 9 = badges in a row
        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 (in pixels)
    end
 
Last edited:

iiGeorgie

Georgie
12
Posts
8
Years
Okay, so this is the code from the post that does the thing, but you'll need to edit a few things.
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 (in pixels)
    y=250 # change to y coordinate of top most badge slot (in pixels)
    imagePositions=[]
    for i in 0...3 #change 3 to total number of rows
      for j in 0...9 #badges in a row
        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 (in pixels)
      end
      x=72 #make this equal to the first x=72 if you change that.
      y+=40 # Change to the distance between the top left corners of two badge slots on top of each other (in pixels)
    end
After you do these changes, you'll need to open your badges image (Graphics/Pictures/badges.png) and make it have 9 badges on each row.
That's it. If you're still stuck, attach the image you use for the trainer cards and I can set up this little segment, explaining as I go along.
EDIT: Oh, if you don't want multiple rows, and just have the specific badges change for each region, use this snippet instead.
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 (in pixels)
    y=250 # change to y coordinate of top most badge slot (in pixels)
    imagePositions=[]
    i=pbGetCurrentRegion(0) # Get the current region
    for j in 0...9 #badges in a row
      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 (in pixels)
    end

Thank you so much! You really are a coding saint! Here's the trainer card.
http://imgur.com/GPjf7MV
 
1,677
Posts
8
Years
  • Age 23
  • Seen today
I'm going to assume that each of the badges are 44 by 44 pixels okay, since I don't know any better.
Code:
    x=34 # change to x coordinate of left most badge slot (in pixels)
    y=264 # change to y coordinate of top most badge slot (in pixels)
    imagePositions=[]
    for i in 0...2 #change 3 to total number of rows
      for j in 0...9 #badges in a row
        if $Trainer.badges[j+i*9]
          imagePositions.push(["Graphics/Pictures/badges",x,y,j*44,i*44,44,44])
        end
        x+=34 # Change to the distance between the top left corners of two badge slots beside each other (in pixels)
      end
      x=34 #make this equal to the first x=72 if you change that.
      y+=50 # Change to the distance between the top left corners of two badge slots on top of each other (in pixels)
    end

This should work
 

iiGeorgie

Georgie
12
Posts
8
Years
I'm going to assume that each of the badges are 44 by 44 pixels okay, since I don't know any better.
Code:
    x=34 # change to x coordinate of left most badge slot (in pixels)
    y=264 # change to y coordinate of top most badge slot (in pixels)
    imagePositions=[]
    for i in 0...2 #change 3 to total number of rows
      for j in 0...9 #badges in a row
        if $Trainer.badges[j+i*9]
          imagePositions.push(["Graphics/Pictures/badges",x,y,j*44,i*44,44,44])
        end
        x+=34 # Change to the distance between the top left corners of two badge slots beside each other (in pixels)
      end
      x=34 #make this equal to the first x=72 if you change that.
      y+=50 # Change to the distance between the top left corners of two badge slots on top of each other (in pixels)
    end

This should work

Thanks so much! How do I take the cards badge placements? Is it from a certain corner or from a middle point? Also my badges aren't 44x44 px they're 32x32, will that be an issue with the card?
 

iiGeorgie

Georgie
12
Posts
8
Years
I'm going to assume that each of the badges are 44 by 44 pixels okay, since I don't know any better.
Code:
    x=34 # change to x coordinate of left most badge slot (in pixels)
    y=264 # change to y coordinate of top most badge slot (in pixels)
    imagePositions=[]
    for i in 0...2 #change 3 to total number of rows
      for j in 0...9 #badges in a row
        if $Trainer.badges[j+i*9]
          imagePositions.push(["Graphics/Pictures/badges",x,y,j*44,i*44,44,44])
        end
        x+=34 # Change to the distance between the top left corners of two badge slots beside each other (in pixels)
      end
      x=34 #make this equal to the first x=72 if you change that.
      y+=50 # Change to the distance between the top left corners of two badge slots on top of each other (in pixels)
    end

This should work

Nevermind don't worry I figured it out, I was just being stupid again. Thank you so much for your help, you're a life saver!
 
Back
Top