MZ Javascript Conditional For Skill & Force action problem

Hello! I am using CGMZ battle command window For some new window options, and I am trying to create an Ultimate type skill that only becomes selectable once a variable is at 3.

As you can see, there are 2 javascript boxes for writing your code: one for the function and one to define when it is selectable.
Screenshot 2024-12-26 141153.png
Screenshot 2024-12-26 141210.png

So what i was planning to do was force action the skill but when i tried it with the attack skill it didnt do anything and just brought me back to the top of the command window. (yes i know i set it to last target but i tried it with random as well. i also did other troubleshooting like changing the actor)
Screenshot 2024-12-26 142523.png

So now i am left with 2 questions:

What is the javascript for enabling the command if a variable hits 3


Why isn't my force action working?

I know the plugin is paid so nobody will look at the code but i think it's just a javascript question, it doesnt have anything to do with the plugin, right?
What is the javascript for enabling the command if a variable hits 3
Code:
return $gameVariables.value(x) >= 3
Why isn't my force action working?
no idea if youre meant to fire off forced actions from within there, but you should have gotten an error in the console for doing what you did. You made subject a number and then tried running forceAction() and BattleManager.forceAction() on that number instead of battler like they expect.
Code:
return $gameVariables.value(x) >= 3

no idea if youre meant to fire off forced actions from within there, but you should have gotten an error in the console for doing what you did. You made subject a number and then tried running forceAction() and BattleManager.forceAction() on that number instead of battler like they expect.
ah, looking at the example in the script call list I see that they used
var subject = $gameTroop.members()[0];
I swapped the top line out for
var subject = $gameParty.members()[0];
but the same thing still happens. sorry if i missed anything, but didnt you identify that as the main problem?

(and by the way, the conditional works perfectly, thank you so much)
didnt you identify that as the main problem?
it was *a* problem, but i dont know enough to tell if its the only one. theres a good chance that this.setWaitMode() is also causing an error in that context, and i cant know if youre even supposed to use forced actions there in general.

Ultimately, i cant tell you the problem. i can see by the pictures on the itch page that skills can be placed somehow, but i cant even access the help file to give it a glance. Youre probably better off asking on the itch page or joining their discord and asking around there
This seems like the hardest way to go about this. A good general rule is to avoid situations where you're trying to use Force Action, it messes with things in the battle system.

There are a number of plugins to add skills directly to the actor command window and make them execute as proper skills chosen for your turn, no coding necessary.

Maybe you're using some of the other features in this plugin, which is fine, but if your primary use is for this, it's overkill. For example, I'm pretty sure I recall testing Victor Engine's Command Replace in MZ.

As far as your code, if you press F8 and go to the Console tab, do you see any errors when it should be run?

Where did this.setWaitMode() come from? It seems almost impossible that this code is being executed by an event interpreter. (there's absolutely no reason it would be)
Maybe you're using some of the other features in this plugin, which is fine, but if your primary use is for this, it's overkill.
Yes, I'm using other features.

As far as your code, if you press F8 and go to the Console tab, do you see any errors when it should be run?
Weirdly enough, nothing at all happens on the console when i use it, but it also never resolves in battle, since once i click it i get booted back to the top of command select.

Where did this.setWaitMode() come from? It seems almost impossible that this code is being executed by an event interpreter. (there's absolutely no reason it would be
Sorry, that was just the one in the example, and i didnt know any others. what would you set as the interpreter?
If you want to add a command that automatically selects a skill for an actor when used, you can use the following js for your command js:

JavaScript:
const mySkillId = 1; // change this number to your skill id
const action = BattleManager.inputtingAction();
action.setSkill(mySkillId);
this.onSelectAction();

This will cause the actor to use that skill when your command is selected.
If you want to add a command that automatically selects a skill for an actor when used, you can use the following js for your command js:

JavaScript:
const mySkillId = 1; // change this number to your skill id
const action = BattleManager.inputtingAction();
action.setSkill(mySkillId);
this.onSelectAction();

This will cause the actor to use that skill when your command is selected.
perfect. absolutely perfect. thank you so much casper!

Original thread: https://forums.rpgmakerweb.com/threads/javascript-conditional-for-skill-force-action-problem.174188/