Script in Battle event question

heejoon0723

Villager
Member
Joined
Nov 11, 2020
Messages
9
Reaction score
0
First Language
ko
Primarily Uses
RMMZ
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.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,755
Reaction score
7,861
First Language
German
Primarily Uses
RMMV
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...
 

heejoon0723

Villager
Member
Joined
Nov 11, 2020
Messages
9
Reaction score
0
First Language
ko
Primarily Uses
RMMZ
Thank you very much for your reply.
Since the language of the tool I use is not English, I will replace it with a slightly modified picture.

abc.png
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,755
Reaction score
7,861
First Language
German
Primarily Uses
RMMV
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.
 

heejoon0723

Villager
Member
Joined
Nov 11, 2020
Messages
9
Reaction score
0
First Language
ko
Primarily Uses
RMMZ
=== 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.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,755
Reaction score
7,861
First Language
German
Primarily Uses
RMMV
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.
 

heejoon0723

Villager
Member
Joined
Nov 11, 2020
Messages
9
Reaction score
0
First Language
ko
Primarily Uses
RMMZ
Thanks to your advice, I solved the problem. Thank you for your kind explanation. :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Both the polls for the 3rd Original Character Contest ended with 5th place ties! So let's break those ties. Vote now for your favorite of the ones tied!


werewolf and his friends added!!

YAY! I just posted my third Guide! Setting up STEAM Integration in RPG Maker MV WITH updated NW.js (huge performance update)
rux
MUCLSES!!! :epicface: :epicface:
If you're reviewing someone else's game, don't focus only on the negative and criticize them. Use positive constructive feedback. As game developers, we need to empower one another; not put each other down.

Forum statistics

Threads
107,503
Messages
1,030,126
Members
139,631
Latest member
tealearl
Top