Script in Battle event question

heejoon0723

Warper
Member
Joined
Nov 11, 2020
Messages
4
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,367
Reaction score
7,676
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

Warper
Member
Joined
Nov 11, 2020
Messages
4
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,367
Reaction score
7,676
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

Warper
Member
Joined
Nov 11, 2020
Messages
4
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,367
Reaction score
7,676
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

Warper
Member
Joined
Nov 11, 2020
Messages
4
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

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,584
Latest member
Faustus2501
Top