• 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?".
  • Forum moderator applications are now open! Click here for details.
  • 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.

Script assistance (@pokemon, message/choice windows)

189
Posts
14
Years
  • Seen Nov 23, 2023
Hey guys,
I've been working on a starter selection screen for my game, and for the most part I have it working, with all the accompanying graphics and whatnot. Granted it's not the fanciest looking thing, but it does its job well enough. I just have a few things I need to address in order to continue working on it.

First up: at present, I've been hardcoding the starter Pokemon and their respective data, images etc into the script. I know I should really be using the @pokemon thing, and getting the names, types and number out of that, but I don't understand how it works, and I couldn't find like a def thing that describes how it operates or how to set it to a particular Pokemon. Oh, and at the completion of the screen, it should add the selected Pokemon to the party. Would someone please elaborate upon this function?

Secondly, I have some questions about message and choice windows. I was wondering if it was possible to display a smaller window, one line high, at the bottom of the screen, and containing text defined in the script. In addition, this window should have attached a choice window thingy with the yes and no thing, ensuring it aligns with the newer sized window. I've included an attachment to illustrate what I mean.

In addition, I've also included my current code. It's a bit messy, unfinished, and will be cleaned up in due time. Here it is:
Spoiler:
I also intend on somehow adding parameters to the script call such that the user can define their own starters without having to modify the code, but I'll get to that one I have to regular script working. Thanks in advance for any help, guys.
Cheers, Jim
 

IceGod64

In the Lost & Found bin!
624
Posts
15
Years
Hey guys,
I've been working on a starter selection screen for my game, and for the most part I have it working, with all the accompanying graphics and whatnot. Granted it's not the fanciest looking thing, but it does its job well enough. I just have a few things I need to address in order to continue working on it.

First up: at present, I've been hardcoding the starter Pokemon and their respective data, images etc into the script. I know I should really be using the @pokemon thing, and getting the names, types and number out of that, but I don't understand how it works, and I couldn't find like a def thing that describes how it operates or how to set it to a particular Pokemon. Oh, and at the completion of the screen, it should add the selected Pokemon to the party. Would someone please elaborate upon this function?

Secondly, I have some questions about message and choice windows. I was wondering if it was possible to display a smaller window, one line high, at the bottom of the screen, and containing text defined in the script. In addition, this window should have attached a choice window thingy with the yes and no thing, ensuring it aligns with the newer sized window. I've included an attachment to illustrate what I mean.

In addition, I've also included my current code. It's a bit messy, unfinished, and will be cleaned up in due time. Here it is:
Spoiler:
I also intend on somehow adding parameters to the script call such that the user can define their own starters without having to modify the code, but I'll get to that one I have to regular script working. Thanks in advance for any help, guys.
Cheers, Jim

Here's an example of properly creating a Pokemon with a script:

Code:
def pbCreatePoke
  poke=PokeBattle_Pokemon.new(PBSpecies::EEVEE,25,$Trainer)
  poke.abilityflag = 2
  poke.happiness=160
  poke.item = PBItems::ORANBERRY
  poke.obtainLevel = 5
  poke.natureflag =  12
  pbAddToParty(poke)
end

This is in the general ballpark of what kind of stuff you might want to do in terms of actually giving the Pokémon.

As for double checking is that's what the player wants, try something like:

Code:
if pbDisplayConfirm(_INTL("is this the Pokémon you want?"))
 pbCreatePoke
 $scene = Scene_Map.new
 return
else
 end

You might need to copy the def pbDisplayConfirm from another script (I think it's in PokemonSave)but that should do what you want.
 
189
Posts
14
Years
  • Seen Nov 23, 2023
Thanks for the assistance, IceGod. I modified the add Pokemon script a bit and added it in the Input::C section, where it belongs, along with the confirmation message. Speaking of which, I didn't have to copy any scripts, I just had to use "Kernel.ConfirmMessage(blahblahblah)".

However, what you suggested only half answers my questions. I still have to hardcode the Pokemon data, and I still need to know how to display a smaller message window (assuming you can. I suspect one would). Thanks for what you did contribute, at least. Now the script actually adds Pokemon. :D
Cheers, Jim.
 

FL

Pokémon Island Creator
2,434
Posts
13
Years
  • Seen today
To displays the message use:

Code:
    @sprites["msgwindow"]=Kernel.pbCreateMessageWindow(@viewport)
    Kernel.pbMessageDisplay(@sprites["msgwindow"],
        _INTL("Insert the text here"))

I suggest you to use '@starterchoice' rather than '$game_variables[26]'. Just put '@starterchoice=0' when the scene is starting. Also, take a look in http://pokemonessentials.wikia.com/wiki/Tutorial:Show_species_introdution
 
189
Posts
14
Years
  • Seen Nov 23, 2023
Okay so this is a huge necropost. Sorry if that's a problem. I've gone back to my Starter Selection screen, and rewritten it from the ground up in order to be able to accept parameters such that it can be initialised with any three Pokémon as specified in the method call.

What I've built seems more or less structurally sound, but I've come to realise the variables passed into the method call have no way of reaching their target destinations. The code compiles, but throws an exception when called due to the "missing" variable values.

As far as I've seen, the only self-contained way I can pass those variables all the way down to the required code is to pass them through each and every method along the way. It's pretty safe to say that with several variables this becomes quite lengthy and unpleasant to read. Is there an easier way by which I might pass these variables though to their intended code?

I've included the code below for your convenience.

Spoiler:
 

FL

Pokémon Island Creator
2,434
Posts
13
Years
  • Seen today
Instead of starter one, starter two, just use an Array, something like:

Code:
        starters=[PBSpecies::BULBASAUR, PBSpecies::CHARMANDER, PBSpecies::SQUIRTLE]
        index = $game_variables[26] - 1
        textPositions.push([_INTL("{1}",PBSpecies.getName(starters[index])),
                                  16,40,1, baseColor,shadowColor])
        textPositions.push([_INTL("{1}",pbGetMessage(MessageTypes::Kinds,starters[index)),
                                  370, 40, baseColor,shadowColor])
        imagePositions.push([_INTL("Graphics/Battlers/%03d",starters[index]),180,8,0,0,-1,-1])
        imagePositions.push(["Graphics/Pictures/boxpoint2",240,200,0,0,-1,-1])
        pbPlayCry(starters[index])
 
189
Posts
14
Years
  • Seen Nov 23, 2023
I think you're missing the point of my rewrite, FL. That solution hardcodes the start selections into the script. I'm trying to make it such that it can use any three Pokémon as denoted by the script call. So, instead of calling pbShowStarterSelection and having to pick between Bulbasaur, Charmander or Squirtle, you could call pbShowStarterSelection(x,y,z) or pbShowStarterSelection(a,b,c) and have the script display choices for completely different sets of Pokémon.

The problem with that is that in order to pass x,y,z/a,b,c to the part of the script that actually displays the scene, I would have to add parameters to several method calls along the way, none of which actually use them. If I could put them straight into a set of quote-unquote "global" variables accessible from anywhere inside that script, that would be really helpful. It'd be kind of like the OO classes I've been writing in C++.
 

FL

Pokémon Island Creator
2,434
Posts
13
Years
  • Seen today
I think you're missing the point of my rewrite, FL. That solution hardcodes the start selections into the script. I'm trying to make it such that it can use any three Pokémon as denoted by the script call. So, instead of calling pbShowStarterSelection and having to pick between Bulbasaur, Charmander or Squirtle, you could call pbShowStarterSelection(x,y,z) or pbShowStarterSelection(a,b,c) and have the script display choices for completely different sets of Pokémon.

The problem with that is that in order to pass x,y,z/a,b,c to the part of the script that actually displays the scene, I would have to add parameters to several method calls along the way, none of which actually use them. If I could put them straight into a set of quote-unquote "global" variables accessible from anywhere inside that script, that would be really helpful. It'd be kind of like the OO classes I've been writing in C++.
Sorry for my misunderstanding!

Since you call a method in a different class, you need, at least, put it in two parameters declarations, there ways to put in only one using a Global Variable ($), but this is really a bad idea, use an Instance Variable (@) instead:

Code:
def pbShowStarterSelection(starterOne, starterTwo, starterThree, nameLater=false)
  pbFadeOutIn(99999) {
     scene=PokemonStarterSelectionScene.new
     screen=PokemonStarterSelection.new(scene)
     screen.pbStartScreen(starterOne, starterTwo, starterThree) # You can put these parameters in the constructor.
  }
end

def pbStartScene(starterOne, starterTwo, starterThree) 
    # Some code
    @starterOne=starterOne
    @starterTwo=starterTwo
    @starterThree=starterThree
    # Some code
  end
So, only use @starterOne, @starterTwo and @starterThree in the rest of the class. For accessing these parameters in other classes, search about attr_accessor, attr_reader and attr_writer.
 
189
Posts
14
Years
  • Seen Nov 23, 2023
Ah, thank you so much! Those instance variables worked a treat! I've got it up and running and working successfully with any given Pokémon, though I've noticed the species number has to be exactly three digits regardless of value; it makes playing the the rand() function slightly less amusing than it should be. In any case, it works exactly as I intended it to work. Again, thanks a bunch!

Spoiler:
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
If you're looking at the %03d part, that only applies to filenames (just like every other script dealing with file names). You can still use pbShowStarterSelection(4,25,1138) and it'll work just fine - filenames here will be 004, 025 and 1138.

%03d means that, when the number (d means "number" here) is turned into a string (% means "turn into string"), it is padded at the beginning so that it's at least 3 digits long. The character used for padding is 0.
 
189
Posts
14
Years
  • Seen Nov 23, 2023
Ah, yes, so it does. It seems I had changed the %03d part to {1} at some point because it wasn't working. A few seconds of looking at other uses of %03d has led me to realise that you have to use sprintf instead of _INTL or it won't work. That must have been why I switched it to {1}, which now I realise takes the value literally and thus doesn't pad it to the required length. Helpful as ever, Maruno.
 
68
Posts
11
Years
  • Seen Nov 12, 2023
If you're looking at the %03d part, that only applies to filenames (just like every other script dealing with file names). You can still use pbShowStarterSelection(4,25,1138) and it'll work just fine - filenames here will be 004, 025 and 1138.

%03d means that, when the number (d means "number" here) is turned into a string (% means "turn into string"), it is padded at the beginning so that it's at least 3 digits long. The character used for padding is 0.
how must I Chance my script, to call it how you say with pbCallPokemonSelect(4,25,1138)?
And how I can show the Name, Type-Picture (like in Summary) and the Graphic of the Pokémon?
Spoiler:
 
189
Posts
14
Years
  • Seen Nov 23, 2023
First you want to add parameters to the relevant methods. I've outlined these in red below. That way, you can call "pbCallPokemonSelect(a,b,c)" like you want to. Then, you want to move those three lines with the instance variables "@blahblah" into the def, "pbStartScene", as indicated in blue. From now on, if you want to access those values from any method in that class, you only need to use "@blahblah". I'll let you figure out what to do with them after that.

Oh, and as a quick side note, there are better ways of encapsulating your left/right input triggers.

Code:
def pbStartScene[COLOR=Red](starterOne,starterTwo,starterThree)[/COLOR]
 @sprites={}
 @select=0
 @viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
 @viewport.z=99999

 @sprites["bg"]=IconSprite.new(0,0,@viewport)
 @sprites["bg"].setBitmap("Graphics/Pictures/Starter_BG")

 [COLOR=Blue]@starterOne=starterOne
 @starterTwo=starterTwo
 @starterThree=starterThree[/COLOR]

 pbFadeInAndShow(@sprites) { update }
end

=================

def pbStartScreen[COLOR=Red](starterOne,starterTwo,starterThree)[/COLOR]
 @scene.pbStartScene[COLOR=Red](starterOne,starterTwo,starterThree)[/COLOR]
 @scene.pbPokemonSelect
 @scene.pbEndScene
end

end

def pbCallPokemonSelect[COLOR=Red](starterOne,starterTwo,starterThree)[/COLOR]
    scene=PokemonPokemonSelectScene.new
    screen=PokemonPokemonSelect.new(scene)
    screen.pbStartScreen[COLOR=Red](starterOne,starterTwo,starterThree)[/COLOR]
end
 
68
Posts
11
Years
  • Seen Nov 12, 2023
thanks :D

but my problem now is, that I can't show the Battler-Picture of the Pokémon, I had used

Code:
imagePositions.push([_INTL("Graphics/Battlers/%03d",@starterOne),136,72,0,0,-1,-1])

or

Code:
@sprites["pokemon"]=IconSprite.new(136,72,@viewport)
@sprites["pokemon"].setBitmap("Graphics/Battlers/%03d",@starterOne)

or

Code:
imagePositions.push([sprintf("Graphics/Battlers/%03d",@starterOne),136,72,0,0,-1,-1])

but nothing happens.... I had use this scripts:

Code:
pbCallPokemonSelect(1,4,7)

and

Code:
pbCallPokemonSelect(001,004,007)
 
189
Posts
14
Years
  • Seen Nov 23, 2023
Hmm, just looking at what you've posted you should be doing okay. I used the sprintf version of what you have up there and I'm not having any problems. There may be a logic error somewhere in your code. It's possible you may have misspelled a variable name or failed to set the value of @starterOne to that of the call parameter... I'd have to see your whole script to know for sure. Check over your code a few more times, call by call, to make sure that what you're coding makes sense.
 
68
Posts
11
Years
  • Seen Nov 12, 2023
So, i solved my problem :) ^^

how i can show the type-picture of my starter?
 
Last edited:
189
Posts
14
Years
  • Seen Nov 23, 2023
As an addendum to what Maruno said, take a look at which type-picture you want to display. The Pokédex uses a different source of type-pictures (pokedexTypes.png) to most other screens (types.png). They can both be drawn the same way, but since the latter is smaller, you'll need to use smaller offset values. It comes down to aesthetic preference, I guess.
 
68
Posts
11
Years
  • Seen Nov 12, 2023
yes :D I had used the types.png :D

next question:

If I displayed this:

You want {1}, the {2}-Pokémon?

{1} = Pokemon-Name (thats not the problem)
{2} = The Pokemon-Type of this Pokémon (If it has two, I want Type1)

how I can show {2}?
 
64
Posts
10
Years
  • Age 36
  • Seen May 29, 2020
I found this:

Spoiler:


So, maybe, make something like:

Spoiler:

This in specific won't work (I don't know much of the specific names in the code yet), but it might help you find what you need. The second and third argument are what is displayed in the text message.
 
Back
Top