How to check if all boolean variables are true or false

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

I want to check if all variables (which are booleans) in an array are true or false.

EG. (VERY basic and stripped down pseudo code just meant to get the point across)

var array = [x, y, z]

func onClick():
	array[0] = false #x to false
	array[1] = false #y to false
	array[2] = false #z to false

func _process(delta):
	#THIS IS THE PART HERE I NEED HELP WITH
	if all of array is false:
		do_thing()

Thank you in advance.

If array[0] == false and array[1] == false and array[2] == false:
   do whatever

umma | 2022-07-11 03:15

Is there not a more efficient way to do this? I am aware of this, but I want to check for ALL at the same time and if they ARE all false then it will do something.

Lazulily | 2022-07-11 03:45

:bust_in_silhouette: Reply From: omggomb

You can also use the in operator for that:

if not false in array:
    print("All entries are true")

I didn’t know this was legal

ReudsFratt92 | 2022-07-11 12:37

Awesome, thank you so much!
This will be very useful.

Lazulily | 2022-07-11 23:06