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,838
Reaction score
7,897
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,838
Reaction score
7,897
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,838
Reaction score
7,897
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


When you thought you'd be finished with the grid, and spend ~8-9 hours on an arrow. How is this more difficult to than player movement?

Still some bugs hiding in there, but it's nearly complete.

I'm having it strictly follow the path a user draws, because there will be booby trap and other similar mechanics where you want to avoid specific cells.
I feel like banging my head against a wall every time I want to find that post that shows all the plugin header codes. Then I think "next time I find it, I'm going to bookmark it". Then I think "wait a minute ... maybe I bookmarked it last time because it took me so long to find it". Check bookmarks, and there it is :)
... a few of my main characters standing around doing nothing lol. I mostly wanted to see them together on screen.

Forum statistics

Threads
107,824
Messages
1,032,449
Members
139,975
Latest member
Lucimountfort
Top