How to use code in a text description?

I'm making a game where one of the characters has a revolver with six chambers, with different bullet types in each chamber. I wanted to make a skill that can't actually be used, but the description of it shows what bullet is in each chamber, this is currently what I have in the description of that skill, was hoping for y'all's input on how to get it to work:


Chamber 1: if($gameVariables.value(4)=0){$gameMessage.add(Empty);}
There are a number of problems with that.

this is currently what I have in the description of that skill
You can't type into the description of a skill and have it execute code.

You can't run code anywhere except the fields in event commands specifically labeled "Script".

if($gameVariables.value(4)=0)
This is incorrect JavaScript syntax. You can't make a number equal 0. Checking whether something is equal to 0 is two ==.

{$gameMessage.add(Empty);}
This is also incorrect syntax. The braces, while harmless, are unnecessary. And the add() method expects a string argument, e.g. "Empty". Just putting a word in code is referring to either a variable or a function.

Also, even if it worked, it doesn't seem like what you'd want to do at all - it wouldn't be doing anything to the skill description, it would be popping up a show text window.

The only thing I can think of would be to use a combination of plugins; Hakuen Studio's Global Text lets you use escape codes anywhere, and his Escape Codes plugin lets you embed JavaScript with an escape code.

So you'd make the description of the skill something like
Code:
=|$gameVariables.value(4) == 0 ? "Empty" : "whatever it is when it's not 0"|=
Man, that's rough to hear, I guess I'll look into a different way of doing that.
If you can store the number in a variable, you can display it using \V[] control code.
So it is something like:

There are \V[101] bullets left in the chamber.
If you can store the number in a variable, you can display it using \V[] control code.
Good point, I didn't realize the help window used drawTextEx().

So the OP could do that, or if they wanted more of their custom text they could use my above suggestion but would only need the Escape Codes plugin, not the Global Text.
When you get the code stuff sorted out, consider having the description of every skill relevant to this bullet mechanic include the text code, so the player sees something like this.

Quick Shot
Code:
Damages an enemy for moderate damage.  This skill always goes first.
Current bullet:  Ice

Snipe
Code:
A powerful and highly accurate shot.  This skill has an activation delay.
Current bullet:  Fire

And so forth. It'd be cleaner and more convenient for the player than having to refer to [random passive] to check the bullet type before every action.
Okay, the way I have it set up now is that you can see the number of the type of bullet in each of the barrels with the \v[] and an item that says what each number correlates to. so the skill will say something like, chamber 1: 0, chamber 2: 1, chamber 3:... 2 etc. and the item will say 0 = empty 1 = normal 2 = explosive... etc. This system kinda sucks tho so right now I'm overhauling the code to use scripts instead of the rpgmaker block code
Okay, the way I have it set up now is that you can see the number of the type of bullet in each of the barrels with the \v[] and an item that says what each number correlates to. so the skill will say something like, chamber 1: 0, chamber 2: 1, chamber 3:... 2 etc. and the item will say 0 = empty 1 = normal 2 = explosive... etc. This system kinda sucks tho so right now I'm overhauling the code to use scripts instead of the rpgmaker block code
You could load the text into your variable instead of numbers.
So \v[123] will hold "empty" instead of 0.
Hopefully I'm not necroposting, but I got a way for it to work by using a script so that the variables are now all text instead of numbers, thank y'all for the help.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-use-code-in-a-text-description.174321/