This is the code I tried, and as I said I want it to make the object be destroyed if the amount of true secrets is less than 8, but the object is being destroyed only when the amount is exactly 7 true secrets. I didn't find some way to count variables like we can count instances using "instance_number".
if global.secretItem[1] = true
if global.secretItem[2] = true
if global.secretItem[3] = true
if global.secretItem[4] = true
if global.secretItem[5] = true
if global.secretItem[6] = true
if global.secretItem[7] = true
if global.secretItem[8] = true{
//nothing happens
}
else{
instance_destroy()}
I suggest you to start indenting your code. What happens is this:
if global.secretItem[1] = true
if global.secretItem[2] = true
if global.secretItem[3] = true
if global.secretItem[4] = true
if global.secretItem[5] = true
if global.secretItem[6] = true
if global.secretItem[7] = true
if global.secretItem[8] = true
{
//nothing happens
}
else
{
instance_destroy()
}
The else statements affects only the last if, so the code gets executed if and only if the first seven secrets are true and the last one is false.
You could use this to simplify things:
if(!(global.secretItem[1] == true &&
global.secretItem[2] == true &&
global.secretItem[3] == true &&
global.secretItem[4] == true &&
global.secretItem[5] == true &&
global.secretItem[6] == true &&
global.secretItem[7] == true &&
global.secretItem[8] == true))
{
instance_destroy();
}
! is the logic negation, && the logic AND
The instance_destroy() line will get executed if any of the secretsItems is false.