#Checking if a variable is true in every single node of a group

1 messages · Page 1 of 1 (latest)

prisma vessel
#

what does break down mean in this case?

novel iron
prisma vessel
#

so, to make this work like the other post said, you will have to start with true, then consider each generator, and set it to false if one is not working. if all are working, then the variable will stay true

novel iron
#

🤦‍♂️

#

I'm pretty sure I understand now.

#

It'd be this, right?

prisma vessel
#

be careful though, you are doing this every frame of your game, 60 times per second. that might not be good for performance

#

no, you need to remove the else

#

after the loop the variable will have remained true of no generator was off

#

and if that is clear to you, you can even remove the == true, since working is a boolean already and it will return true or false
return generator.working

prisma vessel
novel iron
#

Nvm, I just needed a quick break and I got it.

prisma vessel
#

Take a break or the break will take you

dense rivet
#

Hello! maybe you want to do something like this?

// Checking all the generators in the list 'generators'
for nodes in generators:
    // Checking if the current gen of the list isn't powered
    if (nodes.working == false):
        // If the gen are off then updates de var
        all_generators_on = false
        
        // Stops the loop (for loop)
        break
    
    // Updates the var if the current gen is powered
    all_generators_on = true