How to check for enemy index

Magusalfador

Veteran
Veteran
Joined
Jun 15, 2014
Messages
240
Reaction score
41
First Language
English Spanish
Primarily Uses
Hi!! I wanted to add a check when a certain skill is used to see if the Enemy Index number is X, then do something.

Im trying this to Check for first enemy in the troop. Of course it doesn't work =P

Code:
if (target.$gameTroop.members()[0]) {
var text = '<CENTER>' + 'It goes through';
SceneManager._scene._logWindow.push('addText', text);
}
Any help? Thanks!!
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
if (target.$gameTroop.members()[0])

That line, assuming you're checking the target of the skill, should be this:

if (target === $gameTroop.members()[0])
 

Magusalfador

Veteran
Veteran
Joined
Jun 15, 2014
Messages
240
Reaction score
41
First Language
English Spanish
Primarily Uses
Ha ha OMG, I need to rest a bit, how on earth I was trying to check something without the operator? Thanks man.
Can you help me on something else? its really simple, when the above condition is met, I want a variable to be up by one every time, like a counter.

Im using $gameVariables.value(X) += 1 Of course it doesnt work.
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
444
Reaction score
208
First Language
English
Primarily Uses
RMMV
Using value simply checks the value; it can't be changed that way. To change it requires something like this:

$gameVariables.setValue(X, $gameVariables.value(X) + 1)

Strange as it sounds, adding to the variable doesn't have its own function. It has to be done with setValue. The first number is which variable to change, while the second is what to change it to, in this case, the current value + 1.
 

Magusalfador

Veteran
Veteran
Joined
Jun 15, 2014
Messages
240
Reaction score
41
First Language
English Spanish
Primarily Uses
Ok, I understand it pretty well.

Thank you!!!
 

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

Latest Threads

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,083
Members
137,583
Latest member
write2dgray
Top