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

Make picture number depend on a variable

  • 575
    Posts
    12
    Years
    • Seen Feb 7, 2017
    Okay, I know it's unusual, but if I could make the picture number depend on a variable, instead of it being just an integer I determine, it'd make my life so much easier.
    Unfortunately, this can't be done using RMXP only, but I'm not sure if this is possible using Pokemon Essentials. So... is it?
     
    I'm afraid you're going to have to be more specific. Maybe give an example?

    I'm not entirely sure what you're talking about. You can use hashes, if that's what you mean.
     
    I'm afraid you're going to have to be more specific. Maybe give an example?

    I'm not entirely sure what you're talking about. You can use hashes, if that's what you mean.
    I'm talking about the "Show Picture" event command that's present in RMXP. The picture number is simply an integer, and if multiple pictures are displayed at the same time, each must have a different number.

    Instead of doing it via the command "Show Picture" call this script:

    pbShowPicture(number,name,origin,x,y,zoomX,zoomY,opacity,blendType)

    That way you can use a $game_variables or whatever you want to set the number you want.
    Thank you SO MUCH! This really made some things quite easier for me :) !
     
    "pbShowPicture(number,name,origin,x,y,zoomX,zoomY,opacity,blendType)"

    Tried to do with this, but maybe I've made mistake on placing my variable in it

    You mean you actually typed out the words "number", "name", etc.? You're supposed to replace those words with actual values. For example, if you want to use variable 47, you can use this:
    Code:
    pbShowPicture(pbGet(47),"coolpicture",0,100,150)
    This will display the picture called "coolpicture" at coordinates (100, 150) on the screen, under the picture number stored in Game Variable 47. Notice that I didn't fill in the other 4 values. This is because everything from "zoomX" to "blendType" is actually optional, so unless you need to zoom in the picture or change its opacity, you can just leave those alone.
     
    I'm still lost tho

    EDIT: I want a picture to appear from a variable because my random use a variable so 48 and that when choosing starter the randomized pokemon appear as a image.

    You will have to make some adjustments to get the image where you want it, but this will show you the random starter Pokemon and give it to the player as long as variable 48 is the national dex number of that pokemon.
    Code:
    def pbShowRandomStarter
      viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
      viewport.z = 9999
      sprite = Sprite.new(viewport)
      if $game_variables[48] < 10
        sprite.bitmap = Bitmap.new("Graphics\\Battlers\\00" + $game_variables[48].to_s + ".png")
      elsif $game_variables[48] < 100
        sprite.bitmap = Bitmap.new("Graphics\\Battlers\\0" + $game_variables[48].to_s + ".png")
      else
        sprite.bitmap = Bitmap.new("Graphics\\Battlers\\" + $game_variables[48].to_s + ".png")
      end
      commands = []
        commands[cmdYes=commands.length] = "Yes"
        commands[cmdNo=commands.length] = "No"
      choice = pbMessage(_INTL("Would you like this Pokémon?"),commands, 0, nil, 0)
      if choice == cmdYes
        sprite.dispose
        pbAddToParty($game_variables[48],5)
      elsif choice == cmdNo
        sprite.dispose
      end
    end
     
    You will have to make some adjustments to get the image where you want it, but this will show you the random starter Pokemon and give it to the player as long as variable 48 is the national dex number of that pokemon.
    Code:
    def pbShowRandomStarter
      viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
      viewport.z = 9999
      sprite = Sprite.new(viewport)
      if $game_variables[48] < 10
        sprite.bitmap = Bitmap.new("Graphics\\Battlers\\00" + $game_variables[48].to_s + ".png")
      elsif $game_variables[48] < 100
        sprite.bitmap = Bitmap.new("Graphics\\Battlers\\0" + $game_variables[48].to_s + ".png")
      else
        sprite.bitmap = Bitmap.new("Graphics\\Battlers\\" + $game_variables[48].to_s + ".png")
      end
      commands = []
        commands[cmdYes=commands.length] = "Yes"
        commands[cmdNo=commands.length] = "No"
      choice = pbMessage(_INTL("Would you like this Pokémon?"),commands, 0, nil, 0)
      if choice == cmdYes
        sprite.dispose
        pbAddToParty($game_variables[48],5)
      elsif choice == cmdNo
        sprite.dispose
      end
    end

    Hmm, doesn't seems to work
     
    I added it as a script in the script editor, i don't know if it was here

    What GT-Baka gave you is called a "function", which is a piece of code that starts with the keyword "def" followed by its name. Just copy-pasting the function in a Script box doesn't do anything by itself - you also need to CALL it. What you can do is paste GT-Baka's entire code block and paste it to the bottom of the script section PSystem_Utilities, then in your event, put the command "pbShowRandomStarter" inside a Script box.
     
    Oh yeah i'm dumb, I'm used to code with JS, ruby is kinda hard xD

    So I had this issue:

    Spoiler:
     
    Oh yeah i'm dumb, I'm used to code with JS, ruby is kinda hard xD

    So I had this issue:

    Spoiler:

    What value was variable 48 set to when you tried to check to see if it was < a number?

    Edit: It looks like you are trying to add a Pokemon to variable [48] by using it's internal name :AURORUS, instead call it by the national dex number 699.
     
    Last edited:
    Back
    Top