Struggling with a Javascript call inside C2

0 favourites
  • 3 posts
From the Asset Store
94 Inside buildings views - Isometric view - PNG transparent - 2048x2048
  • Hello All,

    I am heavily struggling with getting the below function to be called in C2. Essentially what I am doing, is defining a set number of times for the Correct Answer to occur and when it does occur returns a 1 that I can then display in C2. However, I can't get this to pop in C2 at all...

    I've thoroughly tested the code from a javascript perspective in my environment and it's running perfectly, returning exactly what I expect every step of the way. I have spent too many hours at this point trying to figure the C2 piece out so I am here to ask for help/direction.

    I would be happy to donate or pay for any assistance.

    The function that exists on my website, in the same .js as other functions that I am having no difficulties calling, is shown below. I want it to run in Construct 2, and then return the Value 1 into Construct 2 as a global variable.

    When an event occurs, (e.g. Timer = 0) run this function, a popup occurs on my website and requires you to answer some questions. If you answer the specified number of questions correctly it returns a 1.

    function WaitForCorrectAnswers(num){

    var numCorrect = 0;

    var correctFlag;

    var timer=setInterval(checkAnswer,100);

    function checkAnswer(){

    correctFlag = ShiftCorrectFlag();

    if (correctFlag > 0){



    if (numCorrect >= num){


    var done;

    done = 1;

    return done;




    Appreciate any and all help!



  • probably the way to do it would be to call a c2 function inside the checkanswer() function and set the global from c2.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Where did you put this WaitForCorrectAnswers(num) function ? I can't help you further if you don't post the full runtime script.

    Here is a hint, this function cannot be called anywhere, it should be inside an instanceProto

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)