Can I access the string name for a trait? (Solved)

The question is easy, the solution has proven quite difficult and I am starting to suspect that the string is only accessible through the engine and not through the game. The string, or strings, in question are:
1624973193370.png


Edit, solved:
This is the script I used to implement the names. it can probably be made a lot better.
And ye, it's probably far from optimal in any way shape or form. But I just need it for something specific 😛

/*: * @plugindesc Call this function by writing "setTraitNames()" in a script or script event. * @author Bishiba */ //==================================================================================================================================================================================================================== const traitName = []; //Trait List setTraitNames = function() { //Element Rate for (x = 0; x < $dataSystem.elements.length; x++) { p = "11"; traitName[parseInt(p + (String)(x))] = $dataSystem.elements[x]; } //Debuff Rate for (x = 0; x < $dataSystem.terms.params.length; x++) { p = "12"; traitName[parseInt(p + (String)(x))] = $dataSystem.terms.params[x]; } //State Rate for (x = 1; x < $dataStates.length; x++) { p = "13"; traitName[parseInt(p + (String)(x))] = $dataStates[x].name; } //State Resist for (x = 1; x < $dataStates.length; x++) { p = "14"; traitName[parseInt(p + (String)(x))] = $dataStates[x].name; } //Parameter for (x = 0; x < $dataSystem.terms.params.length; x++) { p = "21"; traitName[parseInt(p + (String)(x))] = $dataSystem.terms.params[x]; } //Ex-Parameter p = "22"; x = 0; traitName[parseInt(p + (String)(x))] = "HIT"; x++; traitName[parseInt(p + (String)(x))] = "EVA"; x++; traitName[parseInt(p + (String)(x))] = "CRI"; x++; traitName[parseInt(p + (String)(x))] = "CEVA"; x++; traitName[parseInt(p + (String)(x))] = "MEVA"; x++; traitName[parseInt(p + (String)(x))] = "MRF"; x++; traitName[parseInt(p + (String)(x))] = "CNT"; x++; traitName[parseInt(p + (String)(x))] = "HRG"; x++; traitName[parseInt(p + (String)(x))] = "MRG"; x = 0; //Ex-Parameter p = "23"; x = 0; traitName[parseInt(p + (String)(x))] = "Threat"; //Target Rate x++; traitName[parseInt(p + (String)(x))] = "Guard"; //Guard Effect x++; traitName[parseInt(p + (String)(x))] = "Recovery"; //Recovery Effect x++; traitName[parseInt(p + (String)(x))] = "MPCR"; //MP Cost Rate x++; traitName[parseInt(p + (String)(x))] = "TPCR"; //TP Charge Rate x++; traitName[parseInt(p + (String)(x))] = "PDMG"; //Physical Damage x++; traitName[parseInt(p + (String)(x))] = "MDMG"; //Magical Damage x++; traitName[parseInt(p + (String)(x))] = "FDMG"; //Floor Damage x++; traitName[parseInt(p + (String)(x))] = "EXP"; //Experience x = 0; //Attack Element for (x = 0; x < $dataSystem.elements.length; x++) { p = "31"; traitName[parseInt(p + (String)(x))] = $dataSystem.elements[x]; } //Attack State for (x = 1; x < $dataStates.length; x++) { p = "32"; traitName[parseInt(p + (String)(x))] = $dataStates[x].name; } } //Get Trait Name getTraitName = function(codeTrait, dataIdTrait) { s = traitName[parseInt(codeTrait + (String)(dataIdTrait))]; return s; } //====================================================================================================================================================================================================================
not even in the engine
that is only a label in the editor, nothing else.

Internally the engine runs completely on IDs. It doesn't even matter to the engine how you name an item, an actor or whatever, it will always be referenced by its ID number.
And the same goes for all parameters and so on.


So you have to take a step back and explain what you want to do with that info, then we might be able to point you to a workaround.
not even in the engine
that is only a label in the editor, nothing else.

Internally the engine runs completely on IDs. It doesn't even matter to the engine how you name an item, an actor or whatever, it will always be referenced by its ID number.
And the same goes for all parameters and so on.


So you have to take a step back and explain what you want to do with that info, then we might be able to point you to a workaround.
I just want the string name for easy referencing within a description. Since it wasn't in $dataStates.traits[0], it only has three values, I was hoping I could still find it somehow.

I will just make my own variables if the situation is as such :/
Don't know if this is what you are looking for, but you can also use

$dataSystem.terms.params[X]
Replace X with:
0-MaxHP, 1-MaxMP, 2-ATK, 3-DEF, 4-MAT, 5-MDEF, 6-AGI, 7-LUK

This works atleast with the parameters.
Thanks, but those are the terms, I want to access the actual trait names. Such as:
1624974822849.png


Seems you knew it wasn't what I was looking for but still good suggestion 🙂
Someone else might be looking for just that!

Don't know if this is what you are looking for, but you can also use

$dataSystem.terms.params[X]
Replace X with:
0-MaxHP, 1-MaxMP, 2-ATK, 3-DEF, 4-MAT, 5-MDEF, 6-AGI, 7-LUK

This works atleast with the parameters.
Then your best bet will probably be to manually input these names in individual variables.

As Andar already explained, these terms are hardcoded into the editor itself and cannot be referenced in-game.
in fact, that code example shows perfectly how the engine uses the ID-numbers for everything without using the names anywhere.
there is absolutely no way you can access the original string, the only way would be to type the names for yourself into a plugin and reference them there.

And really? The REASON why thos names are not used anywhere is because they are translated and different in the editor depending on the language the editor is running.
You can get names for some of the traits (such as parameters or elements) but not all of them (definitely not Ex/Sp parameters). When I needed this for my custom status screen, I added a parameter to the plugin which was just an array of the names for each Ex/Sp parameter, so you'll probably have to either do something similar or just type it out wherever you need it.
This is the script I used to implement the names. it can probably be made a lot better.
And ye, it's probably far from optimal in any way shape or form. But I just need it for something specific 😛

/*: * @plugindesc Call this function by writing "setTraitNames()" in a script or script event. * @author Bishiba */ //==================================================================================================================================================================================================================== const traitName = []; //Trait List setTraitNames = function() { //Element Rate for (x = 0; x < $dataSystem.elements.length; x++) { p = "11"; traitName[parseInt(p + (String)(x))] = $dataSystem.elements[x]; } //Debuff Rate for (x = 0; x < $dataSystem.terms.params.length; x++) { p = "12"; traitName[parseInt(p + (String)(x))] = $dataSystem.terms.params[x]; } //State Rate for (x = 1; x < $dataStates.length; x++) { p = "13"; traitName[parseInt(p + (String)(x))] = $dataStates[x].name; } //State Resist for (x = 1; x < $dataStates.length; x++) { p = "14"; traitName[parseInt(p + (String)(x))] = $dataStates[x].name; } //Parameter for (x = 0; x < $dataSystem.terms.params.length; x++) { p = "21"; traitName[parseInt(p + (String)(x))] = $dataSystem.terms.params[x]; } //Ex-Parameter p = "22"; x = 0; traitName[parseInt(p + (String)(x))] = "HIT"; x++; traitName[parseInt(p + (String)(x))] = "EVA"; x++; traitName[parseInt(p + (String)(x))] = "CRI"; x++; traitName[parseInt(p + (String)(x))] = "CEVA"; x++; traitName[parseInt(p + (String)(x))] = "MEVA"; x++; traitName[parseInt(p + (String)(x))] = "MRF"; x++; traitName[parseInt(p + (String)(x))] = "CNT"; x++; traitName[parseInt(p + (String)(x))] = "HRG"; x++; traitName[parseInt(p + (String)(x))] = "MRG"; x = 0; //Ex-Parameter p = "23"; x = 0; traitName[parseInt(p + (String)(x))] = "Threat"; //Target Rate x++; traitName[parseInt(p + (String)(x))] = "Guard"; //Guard Effect x++; traitName[parseInt(p + (String)(x))] = "Recovery"; //Recovery Effect x++; traitName[parseInt(p + (String)(x))] = "MPCR"; //MP Cost Rate x++; traitName[parseInt(p + (String)(x))] = "TPCR"; //TP Charge Rate x++; traitName[parseInt(p + (String)(x))] = "PDMG"; //Physical Damage x++; traitName[parseInt(p + (String)(x))] = "MDMG"; //Magical Damage x++; traitName[parseInt(p + (String)(x))] = "FDMG"; //Floor Damage x++; traitName[parseInt(p + (String)(x))] = "EXP"; //Experience x = 0; //Attack Element for (x = 0; x < $dataSystem.elements.length; x++) { p = "31"; traitName[parseInt(p + (String)(x))] = $dataSystem.elements[x]; } //Attack State for (x = 1; x < $dataStates.length; x++) { p = "32"; traitName[parseInt(p + (String)(x))] = $dataStates[x].name; } } //Get Trait Name getTraitName = function(codeTrait, dataIdTrait) { s = traitName[parseInt(codeTrait + (String)(dataIdTrait))]; return s; } //====================================================================================================================================================================================================================

Original thread: https://forums.rpgmakerweb.com/threads/can-i-access-the-string-name-for-a-trait-solved.137922/