Why the last line of animation gets to play all the time?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Idleman

I don’t know why it behaves like this. The type is printed out correct but does not matter what the type number is, the ActiveSlot03 animation gets to play all the time. Is that any thing wrong with my code? Thank you.

if event.is_action_released("ui_accept"):
	if type == 1 || 4:
	if type == 2 || 5:
	if type == 3 || 6:
:bust_in_silhouette: Reply From: exuin

You can’t compare a variable to two other values with an or like that. You need to write two comparisons.

Thank you for your help, I took your advice and as I put if type == 1 || type == 4: it works now. There are still some thing about this I don’t quite understand.

With my code in the question, why it could till run and play the ActiveSlot03 all the time?What is the logic behind that?

I used to use write two comparisons before, but once I tried without it, and found out it still works fine. In fact, in the sam script, I have follow code without any issue when running. So I am a bit confused, but I will stick to two comparisons just to be safe.

if slotSelection == 4 || 5:

Idleman | 2021-02-21 00:19

It’s casting the second integer to a Boolean. Every int except 0 casts to true and since your last if statement plays active slot 03 it will always play.

exuin | 2021-02-21 00:22

That makes sense now, thank you for making things clear to me.

Idleman | 2021-02-21 00:32