If script for actor check

Hi,
So, my problem is that this is an event linked to a spell, and i want variables to change depending on the target of the spell but all the IFs are taken into account when i do the spell in question.
It must be a script problem, i'm not very good at it still.
Hey, @le_username_404. It seems that you're using nested if-statements for checking the target of the spell. Meaning that when your program checks to see if actor 3 is targeted, it won't check whether actor 4 or 5 are targeted unless actor 3 is the targeted actor, which is not what you want.

The solution? Be mindful of your indentations. Make sure your decision tree for this spell is laid out like this:

If actor 3 is targeted:
....code
end
if actor 4 is targeted:
....code
end
if actor 5 is targeted:
....code
end
etc...


And not like this:

If actor 3 is targeted:
....code
....if actor 4 is targeted:
........code
........if actor 5 is targeted:
............code
........end
....end
end



Edit: I've discovered this is only a partial solution. Refer to post 3 for more information.
Also, without plugins, that target variable you are checking will be undefined.

Instead, you can check Control Variables -> Game Data -> Last Target Actor ID, e.g.

◆Control Variables:#0001 Check = Last Target Actor ID ◆If:Check = 1 ◆Comment:target actor 1 ◆ :Else ◆If:Check = 2 ◆Comment:target actor 2 ◆ :Else ◆Comment:etc ◆ :End ◆ :End
Hey, @le_username_404. It seems that you're using nested if-statements for checking the target of the spell. Meaning that when your program checks to see if actor 3 is targeted, it won't check whether actor 4 or 5 are targeted unless actor 3 is the targeted actor, which is not what you want.

The solution? Be mindful of your indentations. Make sure your decision tree for this spell is laid out like this:

If actor 3 is targeted:
....code
end
if actor 4 is targeted:
....code
end
if actor 5 is targeted:
....code
end
etc...


And not like this:

If actor 3 is targeted:
....code
....if actor 4 is targeted:
........code
........if actor 5 is targeted:
............code
........end
....end
end



Edit: I've discovered this is only a partial solution. Refer to post 3 for more information.
Also, without plugins, that target variable you are checking will be undefined.

Instead, you can check Control Variables -> Game Data -> Last Target Actor ID, e.g.

◆Control Variables:#0001 Check = Last Target Actor ID ◆If:Check = 1 ◆Comment:target actor 1 ◆ :Else ◆If:Check = 2 ◆Comment:target actor 2 ◆ :Else ◆Comment:etc ◆ :End ◆ :End

Thank to you 2.
For it to work i needed both the check variable and the correct indentations.
Works well now 😀
Great, happy RPG Making! 😂

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/if-script-for-actor-check.164670/