• 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?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • 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.

[Essentials Tutorial] Storing a piece of text in a variable

  • 91
    Posts
    14
    Years
    • Seen Sep 5, 2015
    Someone asked this on 4chan somewhere on the internet and I got the answer.

    This guy wanted to store the player's name into a variable and I was like "how do you even store words on variables?" and got curious myself.

    You need to make a script call like this:
    Code:
    t = "Text!!!!"
    $game_variables[x] = t
    What you just did is replace a variable's value with "Text!!!!". Instead of "words" you can use a scripted value, but then you don't use "". For example
    Code:
    t = $Trainer.name
    $game_variables[99] = t
    Will store the player's name as variable 99. It works like \PN, except you can't use \PN in the script call (it would store "PN").

    You can store other stuff, such as the players trainer class (PKMN Trainer by default I believe) or any other stuff, such as a Mon's nickname? Maybe? OH YES I can teach you that and more. In my example I'll give my player a Chikorita, then I'll name it to whatever and store the mon's nickname. Ready? So you added your mon to the party. Great.
    Code:
    poke=$Trainer.party[0]
    t = poke.name
    $game_variables[x] = t
    First line we find the Pokemon we are going to "edit". We don't edit, but we need a "target" to get values from. You can use other values such as pbFirstAblePokemon or $Trainer.lastPokemon instead of $Trainer.party[partyslotnumber, in our case its the first mon so its 0, 5 being 6th]
    The second line will set the text to be our targetted mon's Nickname. Pretty simple.
    The third line, as before, merely stores the text into the variable.

    Of course to use this new variable as text use \v[x] in a text box.

    I can't code for me mom's life but I figured this out thanks to Google. Hopefully it will help future nubs like yours truly or simply give you a new idea.
     
    $game_variables can actually hold practically any instance of a class (they can hold any, but since they are saved values there are some things that can't be saved in the way essentials does)

    Code:
    poke=PokeBattle_Pokemon.new(1,5)
    $game_variables[100]=poke
    Now that variable is an instance of the PokeBattle_Pokemon class, that specifically is a Bulbasaur at level 5
    If you do that then \v[100] won't be of much use to you, but you can use it for things like giving a player a previously determined pokemon by an npc or something. It's a variable, so its uses are mostly limited by your imagination.
     
    Back
    Top