MZ Call self parameter in menus ?

Hello,

I'm using a plugin to use formulas in description & message box and a plugin to create new parameters.
Both are working fine, but I'd like to know the equivalent of the classic "a.atk" for javascript.

For instance, in "$gameActors.actor(x).atk", "x" refers to the character's position in the database, but I want to display/use the parameter of whoever is reading the description.

As far as I need to select a character to view his skills, I thought I'd use a self param "$gameActors.actor(0).atk", but it doesn't work.
While the plugin I use allows "a.smthg" in the formula, I wish to learn the equivalent in js, or whatever it should be. Some extra bit of control is always handy 🙂

Thanks for your time !
please give a link to the website of the plugin, no one can help you without seeing what that plugin does.

That said, the default storage of the parameters is number-based and not as easy as the summary using atk - which is why the code for adding parameters done by the plugin is important.
For instance, in "$gameActors.actor(x).atk", "x" refers to the character's position in the database, but I want to display/use the parameter of whoever is reading the description.
What does this mean? The player sitting at the computer is the one reading the description 😛

Do you mean the actor that is the current leader of the party? Something else? Where are you creating these messages? Are they skill descriptions and you want it to refer to the actor whose turn it is to input an action? We need more specific details to help you.

As far as I need to select a character to view his skills, I thought I'd use a self param "$gameActors.actor(0).atk", but it doesn't work.
Look at your Actors tab in the database - there is no actor 0. The IDs start at 1.

While the plugin I use allows "a.smthg" in the formula, I wish to learn the equivalent in js, or whatever it should be.
The way you reference actors can vary pretty greatly. The syntax you're using above ($gameActors.actor(x)) is one way, but it depends on you knowing the specific ID of an actor. If you want something to be dynamic, potentially referring to different actors under certain circumstances, we need to know where you are in the game and its code.[/ICODE]
please give a link to the website of the plugin, no one can help you without seeing what that plugin does.

That said, the default storage of the parameters is number-based and not as easy as the summary using atk - which is why the code for adding parameters done by the plugin is important.
No problem, here you go :

-WAY_Core and WAY_EvalText -> allow me to use formulas in descriptions.
EDIT :

-LTN_StatAndSkillLevel -> (paid plugin, can't share it. I just use this one to create new parameters and exploit them, but VisuStella's CoreEngine also allows that.)
EDIT :

But honestly, I don't think it really matters ? as I found it on unrelated threads, isn't it a basic (understand "plugin free") RM MZ command ?

What does this mean? The player sitting at the computer is the one reading the description 😛

Do you mean the actor that is the current leader of the party? Something else? Where are you creating these messages? Are they skill descriptions and you want it to refer to the actor whose turn it is to input an action? We need more specific details to help you.

Those messages are displayed in description boxes in menus (battle and on-map).
Using $gameActors.actor(x).whatever displays the stat "whatever" of x ID specific actor.

I don't want that, as it would display wrong stats/numbers and a wrong result for the formula :

EG : You're a mage using the "attack" skill. I have a custom parameter ("pcr") which increases the damage of the "attack" skill.
But if I set "$gameActors.actor(x).pcr", it would result in the value of player x's pcr. I want to exploit "self" pcr (which would normally be "a.pcr"), which is the mage's own value of said pcr param.


What I want is the js equivalent to "a.whatever", where "whatever" is the param I want to check (a.agi, a.mat etc).

I would understand if this was impossible using the "text" event, as "self" would result to noone, since nobody is previously selected.
But in battles and the skills scene, you do have to select your character to be able to see his skills and their associated descriptions, so I'm pretty sure there is a command for that.


Look at your Actors tab in the database - there is no actor 0. The IDs start at 1.


The way you reference actors can vary pretty greatly. The syntax you're using above ($gameActors.actor(x)[/ICODE) is one way, but it depends on you knowing the specific ID of an actor. If you want something to be dynamic, potentially referring to different actors under certain circumstances, we need to know where you are in the game and its code.


The thing is : everything is working fine and "a.whatever" does the job, BUT I'd just like to learn some more of those useful commands (ie the js equivalent to "a.pcr").

Thanks for your answer guys 🙂
But honestly, I don't think it really matters ? as I found it on unrelated threads, isn't it a basic (understand "plugin free") RM MZ command ?
No, which is why you're being asked where the information is and how you're trying to refer to an actor.

EG : You're a mage using the "attack" skill. I have a custom parameter ("pcr") which increases the damage of the "attack" skill.
So in that specific place, a skill's description in battle, you can try referencing this._actor.

What I want is the js equivalent to "a.whatever", where "whatever" is the param I want to check (a.agi, a.mat etc).
This is the confusing part to try to answer - a.whatever is JavaScript. I'm not sure what you think you're typing there, but it's JS 😛

The letter "a" as a variable that references a specific actor is created within the game's engine for you to use, but everything you type in a damage formula or a notetag eval field is JavaScript.

The thing is : everything is working fine and "a.whatever" does the job, BUT I'd just like to learn some more of those useful commands (ie the js equivalent to "a.pcr").
Again, not really sure what you want here. If the a.whatever is the syntax given to you by the plugin you're using (and, again, that is JavaScript), that's what you should use. There isn't some universal way to refer to "the actor who's significant right now" - that's not the way code works.

In some places it might be a. It might be user. It might be this. It might be this._actor. It might be BattleManager._subject. It might be $gameParty.members()[0] - it all depends on exactly where you're using the code and how.

What you're asking is more complicated than you think.
Also, specifically in your case: I couldn't find an MZ version, but the MV version of WAY_EvalText defines the local variable a differently depending on the current scene. Here are the possibilities, ignoring its built-in compatibility patches:
  • $gameParty.leader() = party leader - on the map;
  • BattleManager.actor() = actor waiting for input - in battle;
  • $gameParty.menuActor() = selected actor (menu) - default.
It does a similar thing for its local item and skill variables. Global variables like $gameParty can be referenced anywhere in the game's code, but local variables can't. Technical details here:

For future reference: an "eval" is just some code that is evaluated at runtime. RMMZ uses a similar thing for the damage formula, for example. It's all JavaScript.
No problem, here you go :
no, that is not what I asked for.
I asked for a LINK, not a name - and the reason is given above where another poster could not find the correct website for one of your plugins and had to go to an MV version.

so again, please provide a link to the plugins you're using.
Thanks for your answers ; first of all, i'm really sorry if it's a bit blur, but you answered my question 🙂

@ATT_Turan : I thought RPG MAKER had his own way of dealing with JS, like a basic library, and that most of the plugins extend libraries : for me "a.agi" for instance was the way MZ handle the objects :S
Should I then use "this._actor" with a ".param" just after ? like "this._actor.agi" to get their agility value ?

@caethyril : That sounds useful thanks !
Would it mean that I have to use two descriptions, one for battle with BattleManager.actor()" "and one for on-map menus with "$gameParty.menuActor()" ?

@Andar : I'm genuinely sorry, I thought I linked the url in my first answer, was on something else and didnt double check. I'll edit my post.

Like Caethyril mentioned, those are indeed for MV :

This one though is for MZ though : https://ltngames.itch.io/stat-skill-levels-plugin

Thanks again for your time !
Would it mean that I have to use two descriptions, one for battle with BattleManager.actor()" "and one for on-map menus with "$gameParty.menuActor()" ?
Do you want different descriptions on different scenes?

If not, you can just use a, because that is exactly why that variable is defined. It's also more efficient as plugin code, because JavaScript cannot compile or optimise evals in advance.

I thought RPG MAKER had his own way of dealing with JS, like a basic library, and that most of the plugins extend libraries : for me "a.agi" for instance was the way MZ handle the objects :S
JavaScript, like pretty much any other language (e.g. English, French, etc), lets you call things whatever you like. A thing remains the same no matter what you name it.

a.agi means "get the value of the property agi defined on the object pointed to by variable a". If a is an object, JS will get its agi property. If a plugin has defined another property pcr on a, then you can get that property in exactly the same way: a.pcr.

Evals can reference variables from their local context, which is how the shortcuts are defined for the damage formula, e.g. var a = this.subject(). (WAY_EvalText does the same sort of thing.) But you can't just use this.subject() anywhere, because this is a JavaScript keyword that references the current scope - see the link in my previous post for details on that. The damage formula, for example, is evaluated in the context of the associated Game_Action instance.
Should I then use "this._actor" with a ".param" just after ? like "this._actor.agi" to get their agility value ?
...you should use a. Isn't that what the plugin is telling you to use? I genuinely don't understand what the whole point of this thread is - when the plugin has given you syntax that will work, why are you trying to use something else instead?

I'm just very confused.

Original thread: https://forums.rpgmakerweb.com/threads/call-self-parameter-in-menus.152596/