Help! Displaying Gold Amount Gained in Battle using variables

Discussion in 'RPG Maker MV' started by Nerdboy, Jan 14, 2017.

  1. Nerdboy

    Nerdboy Veteran Veteran

    Messages:
    78
    Likes Received:
    5
    hi im trying to display Gold amount in battle using \v[#id] to display variable of gold set to control variable = gold from (other) menu.


    problem is i get 0 gold or just [x] displayed where [x] is exactly whats displayed not the gold amount but the syntax.


    im using yanfly's skill core with the pre-valuation lunatic mode to show it in combat. where control variable is set to id 17 and = gold amount from other menu.


    <Pre-Damage Eval>


    x = (Math.floor(Math.randomInt(500) + 50));


    $gameParty.gainGold(x);


    $gameMessage.add(String($gameVariables.value(17)));


    </Pre-Damage Eval>


    ive also tried


    <Pre-Damage Eval>


    x = (Math.floor(Math.randomInt(500) + 50));


    $gameParty.gainGold(x);


    $gameMessage.add(String($gameVariables.value(x)));


    </Pre-Damage Eval>


    ive also tried


    <Pre-Damage Eval>


    x = (Math.floor(Math.randomInt(500) + 50));


    $gameParty.gainGold(x);


    $gameVarables.setValue(x)


    $gameMessage.add(String($gameVariables.value(17)));


    </Pre-Damage Eval>


    ive also tried


    <Pre-Damage Eval>


    x = (Math.floor(Math.randomInt(500) + 50));


    $gameParty.gainGold(x);


    $gameVarables.setValue(x)


    $gameMessage.add("\v[x]");


    </Pre-Damage Eval>


    i dont know what im doing wrong i can definitely display the text message box but its either displaying "0" or "[x]" not the gold amount either total or just from the formula.???
     
    Last edited by a moderator: Jan 14, 2017
    #1
  2. LadyBaskerville

    LadyBaskerville Hell-poodle Veteran

    Messages:
    645
    Likes Received:
    474
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    A few things: 


    When you set a variable to the amount of gold the party has, it only sets the variable to the current amount of gold. When the party gets more gold afterwards, the variable will not update itself - you need to use the event command again. (I don't know the script call for that, but it shouldn't be hard to find - look for Game_Interpreter in the rpg...js files, that is where the event commands are "translated" into Javascript.) I just saw from your other thread that you know how to get the gold amount - $gameParty.gold() - so just set your variable to that value again.


    Second, you are missing an argument in your setValue functions. It should have the id of the variable you want to change, and than the value you want to change it to, like $gameVariables.setValue(17, 1110);


    You also misspelled "$gameVariables" a few times, maje sure that is fixed in your final code.


    In the end you should have the following:


    Set x to a random number


    Give the party x gold


    Set a variable (let's keep it #17) to the party's amount of gold


    Display a message which shows the value of variable #17 (not x) - $gameMessage.add("\v[17]"); should work.


    Hope that helps :)


    Edit: You could also just skip the variable entirely and do gameMessage.add(String($gameParty.gold()); directly
     
    Last edited by a moderator: Jan 14, 2017
    #2
  3. Nerdboy

    Nerdboy Veteran Veteran

    Messages:
    78
    Likes Received:
    5
    this code works but.. not exactly what i really want.


    x = (Math.floor(Math.randomInt(500) + 50));


    $gameParty.gainGold(x);


    $gameMessage.add(String($gameParty.gold() + " Gold count!"));


    when i use $gameMessage.add("\v[17]"); it just displays [17] without the lowercase \v so its recognizing it as a variable but not displaying it.


    i used  $gameVariables.setValue(17, x); but the x i think isn't being set/stored in the id 17. is it possible to do or maybe u cant using yanfly's skill core.


    any help appreciated, thank you LadyBaskerville for your help so far.
     
    #3
  4. Andar

    Andar Veteran Veteran

    Messages:
    27,525
    Likes Received:
    6,150
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV


    where did you use that code? you don't use it in the code sequence you posted.


    It has to be used after the gainGold command but before the gameMessage line, or it will not work as intended.



    Please post a screenshot of your code, do not retype it here.


    If the \v vanishes, then it is recognized as a textcode. But if the [17] remains, then somehow the functions don't detect it as part of the same textcode - and such behaviour is caused by typos half the time. And it has happened many times that people made typos in their game but corrected them when retyping here, so a screenshot showing what exactly you wrote in the game is better for finding such causes.
     
    #4
  5. Nerdboy

    Nerdboy Veteran Veteran

    Messages:
    78
    Likes Received:
    5

Share This Page