• 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

With my script to stop the function from giving the player a pokemon you just need to delete
Code:
pbAddToParty($game_variables[48],5)
.

I can I see the modifications you made?

I have this

def pbShowRandomStarter1
viewport = Viewport.new(150,100,Graphics.width,Graphics.height)
viewport.z = 9999
sprite = Sprite.new(viewport)
if $game_variables[48]
sprite.bitmap = Bitmap.new("Graphics\\Pictures\\Battlers" + $game_variables[48].to_s + ".png")
end
commands = []
commands[cmdYes=commands.length] = "Yes"
commands[cmdNo=commands.length] = "No"

if cmdYes>=0
@name = ""
elsif cmdNo>=0
@name = ""
end
end

Since I already have the "choice" thing from an event, It works but it takes time to make the picture invisible
 
I have this



Since I already have the "choice" thing from an event, It works but it takes time to make the picture invisible

You have to re-add
Code:
sprite.dispose
to each selection of Yes/No, this is what tells the game to remove the image.

Code:
if cmdYes>=0
  @name = ""
  sprite.dispose
elsif cmdNo>=0
  @name = ""
  sprite.dispose
end
 
I just tested your modification and found why nothing is showing.
Code:
if cmdYes>=0

by default this is going to be nil or 0 so your variation of the script is wanting to display the image, but on the same frame receiving a command to delete the image.

Having it framed like this
Code:
choice = pbMessage(_INTL("Would you like this Pokémon?"),commands, 0, nil, 0)
  if choice == cmdYes
    sprite.dispose
  elsif choice == cmdNo
    sprite.dispose
  end
allows the picture to be shown for as many frames as the message box is on screen. I don't have the time this vary moment to find an alternative solution instead of using a message box to stop the sprite from being disposed, but try adding the "choice" bit back in to see if that keeps the sprite on screen for you.
 
Last edited:
With he "choice" bit the problem is that I get 2 times the "yes/no" choice since I have one from the event that ask if I want this pokemon

EDIT: Okay funny things I tested stuff

def pbShowRandomStarter1
viewport = Viewport.new(150,100,Graphics.width,Graphics.height)
viewport.z = 9999
sprite = Sprite.new(viewport)
if $game_variables[48]
sprite.bitmap = Bitmap.new("Graphics\\Pictures\\Battlers" + $game_variables[48].to_s + ".png")
end
commands = []
commands[cmdYes=commands.length] = "Yes"
commands[cmdNo=commands.length] = "No"

if cmdYes>=0
sprite.bitmap = Bitmap.new("Graphics\\Pictures\\Battlers" + "025" + ".png")

elsif cmdNo>=0
sprite.bitmap = Bitmap.new("Graphics\\Pictures\\Battlers" + "025" + ".png")
end
end

But the one with "025" is showing in first so it overwrite the one with "$game_variables[48].to_s"
 
Last edited:
With he "choice" bit the problem is that I get 2 times the "yes/no" choice since I have one from the event that ask if I want this pokemon
Can you delete the Yes/No choice in the event and use the one in the script since it kinda important... Or is there something in your event that is preventing you from using the Yes/No choice in the script?

But the one with "025" is showing in first so it overwrite the one with "$game_variables[48].to_s"
Similarly to what I previously mentioned with the game trying to show the sprite and delete it on the same frame your issue hasn't changed.

Code:
[COLOR="Red"][B][I]if cmdYes>=0[/I][/B][/COLOR]
sprite.bitmap = Bitmap.new("Graphics\\Pictures\\Battlers" + "025" + ".png")
By default the cmdYes will be either nil or 0 (both will act the same way). The game will load the sprite for "$game_variables[48]", but the same frame RPG Maker XP will replace it with "025" since there is nothing telling it to wait before loading the next chuck of code.


If you can send me a screenshot of your event, then I might be able to make a more personalized version of my script that works for your game.
 
Can you delete the Yes/No choice in the event and use the one in the script since it kinda important... Or is there something in your event that is preventing you from using the Yes/No choice in the script?

I tried but the sprite delete itself after 5 seconds when pressing yes or no from the event.

That's the event I have:

Spoiler:
 
I have scripted out your event, copy and paste this.
Code:
def pbShowRandomStarter1
  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
  pbAddToPartySilent($game_variables[48],5)
  commands = []
    commands[cmdYes=commands.length] = "Yes"
    commands[cmdNo=commands.length] = "No"
  choice = pbMessage(_INTL("\\bOak: So, you want " + $Trainer.party[0].name + "?"),commands, 0, nil, 0)
  if choice == cmdYes
    sprite.dispose
    $Trainer.party.delete_at(0)
    $Trainer.clearPokedex
    pbAddPokemon($game_variables[48],5)
    pbPokemonFollow(14)
    $game_switches[3] = false
    $game_variables[7] = 1
    $game_self_switches[[mapid, eventid, 'B']] = true
  elsif choice == cmdNo
    sprite.dispose
    $Trainer.party.delete_at(0)
    $Trainer.clearPokedex
    pbMessage(_INTL("\\bOak: Choose carefully!"))
  end
end


This is a lot so let me explain the questionable parts:

This bit adds the randomized Pokemon into the player's party without them knowing. This might sound silly but it is to call the Pokemon's name in the following message.
Code:
pbAddToPartySilent($game_variables[48],5)


This asks you if you want "Insert Pokemon Name Here"? You must have the pokemon in your party to display the name.
Code:
choice = pbMessage(_INTL("\\bOak: So, you want " + $Trainer.party[0].name + "?"),commands, 0, nil, 0)


These lines will removed the silent Pokemon and clear the Pokedex. You clear the Pokemon and re-add it again if the player selects yes so they get the jingle and the option to nickname their Pokemon.
The Pokedex is cleared just in case the player gets Unown or another pokemon with random forms. You don't want to player to register a form of a Pokemon they don't get to keep.
This is also needed if the player selects no because you don't want them to have it if they say no.
Code:
$Trainer.party.delete_at(0)
$Trainer.clearPokedex


Now you need to make some adjustments:

The 2 numbers 0,0 are for you to change, these move where the picture of the Pokemon will be displayed.
Code:
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)


This line will change the event's self switch to B, however it needs to know which event to change so replace "mapid" with the 3 digit number that represents your map, and replace "eventid" with whatever you named your event or the number of the event if you did not name it.
Code:
$game_self_switches[[mapid, eventid, 'B']] = true


If done correctly all you need to do is call this event.
Code:
script: pbShowRandomStarter1
 
Last edited:
Back
Top