So I'm working with a little script to make images appear depending on the Enemy Troop.
I got it to work fine with troops made out of 1 Enemy, so I went onto 2 Enemies.
Now the problem is that, going back to 1 Enemy, the game checks for the enemyId of a troop member that doesn't exist and crashes.
How would I go about not having it check for inexistent enemyIds so it works fine with whatever number of enemies?
I got it to work fine with troops made out of 1 Enemy, so I went onto 2 Enemies.
Now the problem is that, going back to 1 Enemy, the game checks for the enemyId of a troop member that doesn't exist and crashes.
How would I go about not having it check for inexistent enemyIds so it works fine with whatever number of enemies?
Code:
{var y= ($gameTroop.members()[2].enemyId())};
if (y == 1) {return "img/pictures/Test/1.png";}
if (y == 2) {return "img/pictures/Test/2.png";}
if (y == 3) {return "img/pictures/Test/3.png";}
if (y == 4) {return "img/pictures/Test/4.png";}
if (y == 5) {return "img/pictures/Test/5.png";}