Problems with Variables (Instant Refreshing of Variables)

Discussion in 'Learning Ruby and RGSSx' started by fubai, Jun 5, 2014.

Thread Status:
Not open for further replies.
  1. fubai

    fubai Warper Member

    Messages:
    2
    Likes Received:
    0
    First Language:
    German
    RPG Maker VX Ace

    Hey Guys,

    i hope someone can help me with a little problem i just found.

    In my actual project i'm trying to add the damage Variables of skills into their description text.

    Ex. Deals 20 + \C[11]\v[6]\C[0] damage and knocks back the enemy.

    So far it works fine.

    The value of Variable 6 in this example is the value of an additional stat i added to the game via script (N.A.S.T.Y. Extra Stats by Nelderson)

    So i wrote a common event in which i pair up those variables.

    But now there is the problem that in the skill_scene the value doesn't get updated after the Variable 6 changes it's value. I found out that it works when i pair up the variables again in a single event call but that is not what i want to do every time the value changes (and i can't even think of a way doing it).

    Is there any way to refresh the variables/scenes to always show the actual value of the variable?

    With kind regards

    fubai
     
    Last edited by a moderator: Jun 5, 2014
    #1
  2. BadMinotaur

    BadMinotaur You can do it! Veteran

    Messages:
    260
    Likes Received:
    114
    Location:
    Louisiana
    First Language:
    English
    Primarily Uses:
    RMVXA
    When you pull a variable into text like that, unless the text itself is old somehow, that's the variable's actual value. What is probably happening is that the variable itself isn't being updated when you want it to be updated, causing the unexpected result that you're getting.
     
    #2
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    37,164
    Likes Received:
    11,027
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Variables are static. Their value changes when you do an assignment (Control Variables in event commands, or $game_variables[x] = y in script). If you set a variable to the player's HP, it becomes whatever the HP was at the time you did the assignment. It does NOT say "oh, you want this variable to always be the player's HP, so when the HP changes, the variable will also change."


    If THAT is what you are expecting to happen, that's not how variables work.


    I did write a script called Linked Variables that WOULD let you do that (you say in the script that you want variable 1 to always be Actor 1's HP, then whenever you refer to variable 1, it'll go away and see what Actor 1's HP is). If that's what you're after, do a search in the RGSS3 (Ace) Scripts forum for it.
     
    #3
  4. fubai

    fubai Warper Member

    Messages:
    2
    Likes Received:
    0
    First Language:
    German
    I think i found the best possible way to solve my problem.

    It actual works with a common event in which i set the variable.(It seems that i forgot that a common event actual needs a switch active. Shame on me. xD)

    It runs repetedly in the background and now does it's job. It refreshes the variable as long as you are not in a scene.

    Thanks for your help though ;)
     
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,164
    Likes Received:
    11,027
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Common events conditioned by switches only run while you're on the map.


    If any of those contributors happen to change WHILE you're in the battle screen, the common event isn't running, and the variables won't be updated.


    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
     
    #5
Thread Status:
Not open for further replies.

Share This Page