• 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] Changing Trainer Card Barkground Periodically

6
Posts
14
Years
    • Seen May 26, 2019
    Hello!

    I'm trying to figure out how to change the Trainer Card background based on different milestones throughout the project I'm working on. The general sense is that you start off with a white trainer card, then get a green one, then a red one, etc. throughout the game. A note is that I don't want to change "trainercard.png", just "trainercardbg.png". I figure this is probably easy to do if you know your way around the script, but unfortunately I'm not too good at it.

    Any and all help is appreciated! 😊
     
    233
    Posts
    5
    Years
    • Seen Oct 9, 2023
    The PScreen_TrainerCard script section handles the background, so you just need to replace this bit near the top:
    Code:
    if $Trainer.isFemale? && background
      addBackgroundPlane(@sprites,"bg","Trainer Card/bg_f",@viewport)
    else
      addBackgroundPlane(@sprites,"bg","Trainer Card/bg",@viewport)
    end

    with something like:
    Code:
    if MILESTONE2 # Replace with your second milestone
      addBackgroundPlane(@sprites,"bg","Trainer Card/bg_r",@viewport)
    elsif MILESTONE1 # Replace with your first milestone
      addBackgroundPlane(@sprites,"bg","Trainer Card/bg_g",@viewport)
    else # When player has not achieved any milestones yet
      addBackgroundPlane(@sprites,"bg","Trainer Card/bg",@viewport)
    end
    Of course, you can extend this to have as many milestones and backgrounds as you want by adding more if-statements.
     
    Last edited:
    6
    Posts
    14
    Years
    • Seen May 26, 2019
    The PScreen_TrainerCard script section handles the background, so you just need to replace this bit near the top:
    Code:
    if $Trainer.isFemale? && background
      addBackgroundPlane(@sprites,"bg","Trainer Card/bg_f",@viewport)
    else
      addBackgroundPlane(@sprites,"bg","Trainer Card/bg",@viewport)
    end

    with something like:
    Code:
    if MILESTONE2 # Replace with your second milestone
      addBackgroundPlane(@sprites,"bg","Trainer Card/bg_r",@viewport)
    elsif MILESTONE1 # Replace with your first milestone
      addBackgroundPlane(@sprites,"bg","Trainer Card/bg_g",@viewport)
    else # When player has not achieved any milestones yet
      addBackgroundPlane(@sprites,"bg","Trainer Card/bg",@viewport)
    end
    Of course, you can extend this to have as many milestones and backgrounds as you want by adding more if-statements.

    Thanks for the response!

    Would "MILESTONE1", "MILESTONE2" correspond with a switch/variable/comment/script command in the editor? I apologize if it's obvious, I have a really low comprehension of scripting. Thanks again.
     
    233
    Posts
    5
    Years
    • Seen Oct 9, 2023
    Thanks for the response!

    Would "MILESTONE1", "MILESTONE2" correspond with a switch/variable/comment/script command in the editor? I apologize if it's obvious, I have a really low comprehension of scripting. Thanks again.

    It could correspond to any conditional statement. In your case, global switches will probably be the easiest and most readable to use. For example, for your first milestone, you can have a Global Switch 42 (or whatever number you choose) that gets set to "true" when the player has reached the milestone, so then "MILESTONE1" becomes "$game_switches[42]". Then you can set up more global switches for your other milestones and do the same.
     

    Ego13

    hollow_ego
    311
    Posts
    6
    Years
  • If you have multiple milestones I'd recommend using a global variable and just increase it by 1 when the player hits the milestone. It's less switches to keep track of and even easier to read imo
     
    Back
    Top