MZ [SOLVED- Thanks to TheoAllen] Call Variable, in text decimal.

I posted in the wrong forum before, so I have to delete that.
But I am struggling trying to call a normal variable, and the gold in a custom menu with decimals.
So it comes out as, 1,430.00 and not 1430. It's been bugging my OCD bad, I am terrible at JS.
It's really hard for me, with my learning disability. But I'm trying.

I've looked at:
But I don't see anything for displaying text in a string, or I'm being dumb again and did not see it.

Only thing I've found after days, is this.
Steam Forums suggestion: $gameParty._gold.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")
It just outputs a )

Google, RPGM Forums: $gameVariables.value(34).toLocaleString("en", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
It works for storing the value, but I need it to call it and output as decimal.

It's probably something simple, I just need help I can't figure it out. Somebody please help.
ScreenShot-0021.png
and output as decimal.
For what reason?
For what reason?
? Show it displays in my custom menu. Wait did I not say that sorry.

The gold is just how much they have.
Several Variables are to store things like.
Money spent, Money found, money from quests.

I have bought many plugins, one is HUD Maker Pro, because I can't make my own plugin.
$40 was worth it, I love how easy it is to use, I'm just really stuck on this part.

At first, I thought I could just store the formatted Values, it worked. But adding to them messed it up.
So a value stored a 345.00, + 50 ended up as 345.0050.

II figured it would just be easier to leave them all in one bunch, and separate them in just that one menu. I hope that makes sence.
At first, I thought I could just store the formatted Values, it worked. But adding to them messed it up.
So a value stored a 345.00, + 50 ended up as 345.0050.
Of course, they will mess up.
I don't know HUD Maker pro so I can not help you with that.

However, most of the time making plugins or coding a menu works like this.
You calculate everything in the back then convert it to the formatted text.
So you don't format the number then add + 50. But you add +50 first then format the text.
Of course, they will mess up.
I don't know HUD Maker pro so I can not help you with that.

However, most of the time making plugins or coding a menu works like this.
You calculate everything in the back then convert it to the formatted string.
So you don't format the number then add + 50. But you add +50 first then format the text.
I just uses the default code from MZ, what is the call to show the text, and a string?
Is where I'm stuck. All the videos I find, are for MV and don't show how to call it with $game vars.

But thanks for trying, I will keep looking and hope someone might know how.
All the videos I find, are for MV and don't show how to call it with $game vars.
MV video works in MZ. Most of the time.
Also. You have tried it yourself with
$gameVariables.value(34).toLocaleString("en", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
Which should work as expected.

The only piece of the puzzle that left remains for me is
At first, I thought I could just store the formatted Values, it worked. But adding to them messed it up.
So a value stored a 345.00, + 50 ended up as 345.0050.
When this happens.

Or wait, maybe this is what you mean.
Code:
$gameParty._gold.toLocaleString("en", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
MV video works in MZ. Most of the time.
Also. You have tried it yourself with

Which should work as expected.

The only piece of the puzzle that left remains for me is

When this happens.

Or wait, maybe this is what you mean.
Code:
$gameParty._gold.toLocaleString("en", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
Storing it formatted works fine, I just need to call a normal value in my menu, and have the code make it formatted when it's displayed. To avoid the other errors.

Edit: Sorry for not being clear enough on what I am trying to do.
Educate me with how HUD Maker Ultra pro works.
And I might come up with a solution.

Storing it formatted works fine
What do you mean by "storing"? where it is stored?

I just need to call a normal value in my menu, and have the code make it formatted when it's displayed.
Why do you need to call the normal value in the menu?
Does the calculation (like adding +50) happen there?
Educate me with how HUD Maker Ultra pro works.
And I might come up with a solution.


What do you mean by "storing"? where it is stored?


Why do you need to call the normal value in the menu?
Does the calculation (like adding +50) happen there?
No, no calculation needs to be done. I have all the values stored through other plugins and setting variables. It's just a normal Variable, I want to load it in my menu so the player can see their extra stats I have made using variables.

Here is the tool I bought, what it does is makes a menu and loads it in the game.
Now it can load any variable, anything inside MZ, it just don't output it with decimals.
Or I don't know how to make it do that.

Edit: It also has free version, minus Buttons and special affects.

That you can try and see what I mean if that helps?
I get the idea of how HUD Maker Ultra works, although I haven't tried.
But so far, you haven't explained what you actually did and what was the result in detail. Only through text. Here is my thought so far.

You posted this image.
index.php


You use the number 1430 as an example, say that is our gold right now.
You use the code $gameParty._gold.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") in which the output value that is displayed in the menu should look like 1,430 without modifying the original gold value. The gold value is not modified. It is still in number data type.

Later, you want it to be like 1,430.00 which should be as simple as modifying the code to
Code:
$gameParty._gold.toLocaleString("en", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
I saw no problem here, the dynamic text input should correctly show the formatted number as it should. Yet you keep mentioning storing and calculation problems which I have no idea what you mean by that. Furthermore, you said there was no calculation that happened in the HUD.

Later, I found out that you mentioned this.
I have all the values stored through other plugins and setting variables.
That might be another piece of the puzzle.

Tell me, was the picture you sent here was the actual problem you're trying to solve, or was it just an example of something you haven't tell us because for a sake of simplifying the question?

How does the output like in the HUD? you haven't shown that to us.
I get the idea of how HUD Maker Ultra works, although I haven't tried.
But so far, you haven't explained what you actually did and what was the result in detail. Only through text. Here is my thought so far.

You posted this image.
index.php


You use the number 1430 as an example, say that is our gold right now.
You use the code $gameParty._gold.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") in which the output value that is displayed in the menu should look like 1,430 without modifying the original gold value. The gold value is not modified. It is still in number data type.

Later, you want it to be like 1,430.00 which should be as simple as modifying the code to
Code:
$gameParty._gold.toLocaleString("en", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
I saw no problem here, the dynamic text input should correctly show the formatted number as it should. Yet you keep mentioning storing and calculation problems which I have no idea what you mean by that. Furthermore, you said there was no calculation that happened in the HUD.

Later, I found out that you mentioned this.

That might be another piece of the puzzle.

Tell me, was the picture you sent here was the actual problem you're trying to solve, or was it just an example of something you haven't tell us because for a sake of simplifying the question?

How does the output like in the HUD? you haven't shown that to us.
So in the menu maker, you can call any variable like this.
EWdit: I messed up the order sorry, that variable is for expensices. Not gold.
ScreenShot-0025.png
ScreenShot-0022.png
And in game it looks like this.
ScreenShot-0023.png
And the players money looks like this.
ScreenShot-0024.png

All I want, is for it to add a decimal in the value. I hope that helps. the code I tried was to store it, but I need a way to call it and make it do the decimal. Sorry, It's been hard today, my OCD went crazy and nervous ticks from this issue bugging me. I forget to try and explain better.
I think I see the issue now. If I may guess, this is what is happening and your flow of thinking.

You use variable 34 to store the gold variable.
You want to show variable 34 in decimal format.
But you also want to use variable 34 as a part of the calculation somewhere else?
Is "cash on hand" stored in variable 34?

Also, have you tried instead of using variables in the dynamic text input, you use code instead and put this on the code input field?
Code:
$gameVariables.value(34).toLocaleString("en", { minimumFractionDigits: 2, maximumFractionDigits: 2 }

side note: 34 is a funny coincidence number if you know what I mean.
I think I see the issue now. If I may guess, this is what is happening and your flow of thinking.

You use variable 34 to store the gold variable.
You want to show variable 34 in decimal format.
But you also want to use variable 34 as a part of the calculation somewhere else?
Is "cash on hand" stored in variable 34?

Also, have you tried instead of using variables in the dynamic text input, you use code instead and put this on the code input field?
Code:
$gameVariables.value(34).toLocaleString("en", { minimumFractionDigits: 2, maximumFractionDigits: 2 }

side note: 34 is a funny coincidence number if you know what I mean.

I feel like I've tried that one before, but this is the error it gives.
Code:
Ultra Base - Custom Code
Error-- Code: --return "$gameVariables.value(34).toLocaleString("en", { minimumFractionDigits: 2, maximumFractionDigits: 2 })";
-------------Error: --SyntaxError: Unexpected identifier------------

Is there a better way to simply call the value and string?
Am I suppose to put player. first or something.
but this is the error it gives.
Was this an error in the HUD Maker Ultra or when you were testing in RPG Maker?
Was this an error in the HUD Maker Ultra or when you were testing in RPG Maker?
Yes. If I remove the ending ) no error, but nothing shows up.

I noticed one tab has math on it, but not sure if it would help.
ScreenShot-0026.png
You are not answering my question.
You are not answering my question.
I meant yes, it was in MZ in test mode.
Interesting. For a sake of testing, what happens if you put a code that is just written like this
Code:
$gameVariables.value(34)
Interesting. For a sake of testing, what happens if you put a code that is just written like this
Code:
$gameVariables.value(34)
No errors in test mode.
I tried it 4 different ways.
Just $gameVariables.value(34) (Nothing shows up)
Then $gameVariables.value(34); (It prints out the same code, but in text)
Then return "$gameVariables.value(34)"; (Nothing shows up)
I tried placing it in just plain test. "Why do you hate me $gameVariables.value(34)?", shows up as "Why do you hate me ?"

I checked each tab, thinking maybe it don't go in code. or maybe it was another tab for game script.
I don't know what's going on, it's so frustrating. I did nothing on my game all day but try and fic this.

The maker still has not replied, I think he is MIA. Hope their ok.
And thank you, for trying to help so much. And sorry for the replies not giving you an answer. I think it in my head "the reply", but type something else.

Only thing I can say, is if you get time, download the free version, and try to call it in a test menu. I really don't know.
I downloaded the HUD Maker, and by default, the code field provides return "";
Now I know where this is going. There is one case you haven't tried.
Code:
return $gameVariables.value(34)
Do not put quote on it.

Original thread: https://forums.rpgmakerweb.com/threads/solved-thanks-to-theoallen-call-variable-in-text-decimal.139546/