in battle event, I wrote a script.
var i;
var a=0;
for (i = 0; i < 8; i++) {
if ($gameTroop.members().mp == 0) { a=1; break; }
}
if (a==0) {'Action'}
If the first conditions are not met, the action should be executed with a=0. But it can't. I wonder why.
please post a screenshot of the troop event with that script.
there are a lot of reasons why nothing happened, and they start with the question on the conditions of the troop event - does it even start?
and a lot more problems that have nothing to do with the code inside the script box.
then there is a problem that in the code above you never specified which troop member to check, that code can never work for that alone. But that might simply a copy/paste error as you did define i, just never used it - in a screenshot we can see if the code given to the engine is really what you pasted above...
javascript needs === for comparison, not ==
EDIT:
additionally keep in mind that state duration 1 means current turn only, applying it at end of turn means that it will be removed before next turn.
=== also does not work.
I tried to make it simpler, but it doesn't work even if I write it as below.
------------------------ Condition : 0+1x / interver : turn------------
var i;
var a=0;
if ($gameTroop.members()[0].isAlive() { a = 1; break; }
if (a ===0) {$ameTroop.members()[3].addState(4);}
if (a ===1) {$ameTroop.members()[3].addState(5);}
---------------------------------------------------------------------------
To give an example of my question, I purposely composed it with if instead of using else.
'a' should be 0 or 1, but it doesn't work. (a==0 also not work). I think I missed something because I'm a beginner.
in that case add some commands to show the values while the code is running.
that is always the first step: trace the commands until you know which one doesn't work.
because at this moment, you can't even see if the troop event is running at all since it has no form of output.
Thanks to your advice, I solved the problem. Thank you for your kind explanation. 🙂