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,778
Reaction score
7,872
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,778
Reaction score
7,872
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,778
Reaction score
7,872
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. :)
 

Latest Threads

Latest Posts

Latest Profile Posts

3am me: So how do you feel about a character inviting their own character portrait to a tea party? =D

3pm me: //facepalms
I turned 17 two months ago and I feel like I've grown (personality-wise) more in this 1 year than all the 16 years I had lived combined.
Ugh, I may have been cumbersomely eventing a bunch of stuff I could have easily done changing the tileset "Passage (4 dir)" and "Ladder" options. Oops :D
I have no idea why some of the program "splash screen" always on top. E.g, RMMZ loading screen stuck on the top blocking anything I want to do until it fully loaded. What is even the purpose?
One of the secret places in the game.

Forum statistics

Threads
107,640
Messages
1,031,076
Members
139,763
Latest member
Kesharikbrando
Top