True/False Statement with Trigger Regions


#1

I’m trying to create a puzzle with trigger regions and have been able to successfully have all the pieces enter the trigger region, which then starts a timeline that displays a “Success!” message.

var Cold_PrepTable = false
var Bottle_Holder = false
var n38032077_png = false
var n791691_png = false
var n593010_png = false
var n592576_png = false
var n591414_png = false

symbol.controllers.Cold_PrepTable.elements.Correct.on(“complete”, () => {
Cold_PrepTable = true

if (Bottle_Holder === true){
    
    if (n38032077_png === true){
        
         if (n791691_png === true){
             
            if (n593010_png === true){
                
                if (n592576_png === true){
                    
                    if (n591414_png === true){
  
        symbol.controllers.Success_Timeline.elements.Success_Timeline.play();
                 }
               }
            }
       }
    }	
}

});

symbol.controllers.Bottle_Holder.elements.Correct.on(“complete”, () => {
Bottle_Holder = true

if (Cold_PrepTable === true){
    
     if (n38032077_png === true){
         
          if (n791691_png === true){
             
            if (n593010_png === true){
                
                if (n592576_png === true){
                    
                    if (n591414_png === true){
       
       symbol.controllers.Success_Timeline.elements.Success_Timeline.play();
                }
           }
        }
      }
   }
}

});

symbol.controllers.n38032077.elements.Correct.on(“complete”, () => {
n38032077_png = true

if (Cold_PrepTable === true){
    
     if (Bottle_Holder === true){
         
          if (n791691_png === true){
                
                if (n592576_png === true){
                    
                    if (n591414_png === true){
       
       symbol.controllers.Success_Timeline.elements.Success_Timeline.play();
                }
           }
        }
    }
}

});

symbol.controllers.n791691.elements.Correct.on(“complete”, () => {
n791691_png = true

if (Cold_PrepTable === true){
    
     if (Bottle_Holder === true){
         
          if (n38032077_png === true){  
             
            if (n593010_png === true){
                
                if (n592576_png === true){
                    
                    if (n591414_png === true){
       
       symbol.controllers.Success_Timeline.elements.Success_Timeline.play();
                    }
               }         
           }
        }
    }
}

});

symbol.controllers.n593010.elements.Correct.on(“complete”, () => {
n593010_png = true

if (Cold_PrepTable === true){
    
     if (Bottle_Holder === true){
         
          if (n38032077_png === true){  
             
            if (n791691_png === true){
                
                if (n592576_png === true){
                    
                    if (n591414_png === true){
       
       symbol.controllers.Success_Timeline.elements.Success_Timeline.play();
                    }
                }
            }
        }
    }
}

});

symbol.controllers.n592576.elements.Correct.on(“complete”, () => {
n592576_png = true

if (Cold_PrepTable === true){
    
     if (Bottle_Holder === true){
         
          if (n38032077_png === true){  
             
            if (n791691_png === true){
                
                if (n593010_png === true){
                    
                    if (n591414_png === true){
       
       symbol.controllers.Success_Timeline.elements.Success_Timeline.play();
                    }
               }
            }
        }
    }
}

});

symbol.controllers.n591414.elements.Correct.on(“complete”, () => {
n591414_png = true

if (Cold_PrepTable === true){
    
     if (Bottle_Holder === true){
         
          if (n38032077_png === true){  
             
            if (n791691_png === true){
                
                if (n593010_png === true){
                    
                    if (n592576_png === true){
       
       symbol.controllers.Success_Timeline.elements.Success_Timeline.play();
                    }
               }
            }
        }
    }
}

});

I then created a “reset” button for when the the button is hit, the pieces go back to their original position (off to the side) and the timeline disappears.

parent.on(“pointerdown”, (e) => {
symbol.controllers.Cold_PrepTable.elements.Incorrect.activate();
symbol.controllers.Bottle_Holder.elements.Incorrect.activate();
symbol.controllers.n38032077.elements.Incorrect.activate();
symbol.controllers.n791691.elements.Incorrect.activate();
symbol.controllers.n593010.elements.Incorrect.activate();
symbol.controllers.n592576.elements.Incorrect.activate();
symbol.controllers.n591414.elements.Incorrect.activate();
symbol.controllers.Success_Timeline.elements.Success_Timeline.reset();
symbol.controllers.Success_Timeline.elements.Hide.activate();
});

The problem I am running into is when one piece enters their trigger region again, the “Success!” timeline message automatically pops up, even though the entire puzzle hasn’t been completed.


#2

Hi, the reset button should reset to false all your variables, too.


#3

…and you could also use logical operator ( && ) instead of stacking up if statements.
Example:

if ( Bottle_Holder && n38032077_png && n791691_png && n593010_png && n592576_png && n591414_png )
symbol.controllers.Success_Timeline.elements.Success_Timeline.play();