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

An odd way to run variables

26
Posts
9
Years
    • Seen Nov 14, 2023
    Does anyone know how to change a variable using the script editor?
    I think I have everything thing else I need with it, but what I am doing requires an item to set a variable to a different amount at certain times when you use it.
    All I should need is the basic call for it.
    Thank you in advanced
     

    Auraluxe

    ↞The Swashbucklin' Fool↠
    33
    Posts
    14
    Years
  • Sorry if this is of no help, but is this what you're looking to do?

    forums.rpgmakerweb.*com/index.php?/topic/18927-need-help-with-using-items-at-specific-times/

    (Asterisk 'cuz I don't have 15 posts. Derp.)
     
    26
    Posts
    9
    Years
    • Seen Nov 14, 2023
    Sigh
    Once again I have been typing it wrong.
    Thank you
    I will edit this post to tell you if that works for what I am doing.
     

    Nickalooose

    --------------------
    1,309
    Posts
    16
    Years
    • Seen Dec 28, 2023
    If you go to where the item is used (Item Effects), just add
    Code:
    $game_variables[[COLOR="Red"]x[/COLOR]]=[COLOR="Blue"]y[/COLOR] if [COLOR="Magenta"]something[/COLOR]
    Where:
    x = your variable number.
    y = whatever number or letter or word or whatever.
    something = map id, weather effect etc.
     
    26
    Posts
    9
    Years
    • Seen Nov 14, 2023
    Ok so once I add the variables to the items effect, it doesn't work. Does anyone know what else needs to be done?
     

    Nickalooose

    --------------------
    1,309
    Posts
    16
    Years
    • Seen Dec 28, 2023
    Well that's all that needs to be done... If it doesn't work then you've done it wrong.
    Noone can help you if you don't do it right.

    Code:
    ItemHandlers::UseOnPokemon.add(:RARECANDY,proc{|item,pokemon,scene|
       if pokemon.level>=PBExperience::MAXLEVEL || (pokemon.isShadow? rescue false)
         scene.pbDisplay(_INTL("It won't have any effect."))
         next false
       else
         pbChangeLevel(pokemon,pokemon.level+1,scene)
         scene.pbHardRefresh
         [COLOR="Red"]$game_variables[32]=4[/COLOR]
         next true
       end
    })

    So at any point you use a Rare Candy here, and it works, the variable 32, will always be set as 4... Learn this... Cause this is exactly what was explained.
     
    26
    Posts
    9
    Years
    • Seen Nov 14, 2023
    This is what I have set up, and it keeps crashing

    Also, sorry about the quality, I only have Internet on my phone, not my computer.


    Never mind, I see what happened.
     
    Last edited:
    32
    Posts
    9
    Years
    • Seen Aug 16, 2016
    If you go to where the item is used (Item Effects), just add
    Code:
    $game_variables[[COLOR=Red]x[/COLOR]]=[COLOR=Blue]y[/COLOR] if [COLOR=Magenta]something[/COLOR]
    Where:
    x = your variable number.
    y = whatever number or letter or word or whatever.
    something = map id, weather effect etc.


    for anyone like me, who doesn't find it so obvious how to put a word for y:

    it must be 'word', without the ' you'll get an error. numbers of course don't need this.

    this is useful for simple password events:

    pbSet(XX,pbEnterText("password?",1,12))
    conditional branch: script: $game_variables[XX]=='slowpoketail'

    i think the rest is clear
     

    Nickalooose

    --------------------
    1,309
    Posts
    16
    Years
    • Seen Dec 28, 2023
    Correct, words should use Quotes ( "my words" ), numbers have no need, scripts do not use quotes either.
     
    Back
    Top