Help with conditions

0 favourites
  • 2 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I've got a condition for is logged in but every 5 seconds(When I call the action) it literally cycles through both true and inverted references.I'm completely stumped as to why this problem is occuring. Can someone please help me figure out what exactly I'm doing wrong here? I have a condition in the edittime as such:

    AddCondition(6,     0, "Is user logged in", "Login/Logout", "Is user logged in", "True if currently being viewed inside Facebook by a logged in user.", "IsLoggedIn");

    The condition in runtime is this:

    Cnds.prototype.IsLoggedIn = function ()

         {

              if(currentstatus == "Validated User"){return true;}

              else if(currentstatus == "Logged In No Install"){return false;}

              else if(currentstatus == "Not On Facebook"){return false;}

              else return false;

         };

    The declaration for currentstatus is at the very top:

    // ECMAScript 5 strict mode

    "use strict";

    assert2(cr, "cr namespace not created");

    assert2(cr.plugins_, "cr.plugins_ not created");

    var currentstatus = "unknown";

    The changing point for this currently is run from two spots, one is under the FB init function, and the second is a called action. Both are identical copies of each other. And here it is:

    FB.getLoginStatus(function(response) {

         if (response["status"] == 'connected') {

          // the user is logged in and has authenticated your

          // app, and response.authResponse supplies

          // the user's ID, a valid access token, a signed

          // request, and the time the access token

          // and signed request each expire

          fbStatus = "Validated User";

          fblogoutcheck = true;

           fbUserID = response["authResponse"]["userID"];

           UserAccessToken = response["authResponse"]["accessToken"];

           UserAccessTokenExpiresIn = response["authResponse"]["expiresIn"];

           UserSignedRequest = response["authResponse"]["signedRequest"];

           if(currentstatus != "Validated User"){currentstatus = "Validated User";fblogoutcheck = true;fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnLoggedIn, fbInst);}       

          fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnLoggedIn, fbInst);

          fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnAPILoaded, fbInst);

          }

          else if (response["status"] == 'not_authorized') {

         fblogoutcheck = false;

           fbStatus = "Logged In No Install";

           fbUserID = 0;

           UserAccessToken = "";

           UserAccessTokenExpiresIn = 0;

           UserSignedRequest = "";

           if(currentstatus != "Logged In No Install"){currentstatus = "Logged In No Install";fblogoutcheck = false;fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnNotInstalled, fbInst);}

           fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnNotInstalled, fbInst);

           fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnAPILoaded, fbInst);

           // the user is logged in to Facebook,

           // but has not authenticated your app

          } else if (response["status"] == 'unknown') {

         fbStatus = "Not On Facebook";

         fblogoutcheck = false;

         fbUserID = 0;

           UserAccessToken = "";

           UserAccessTokenExpiresIn = 0;

           UserSignedRequest = "";

           if(currentstatus != "Not On Facebook"){currentstatus = "Not On Facebook";fblogoutcheck = false;fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnFacebookOut, fbInst);}

           fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnFacebookOut, fbInst);

           fbRuntime.trigger(cr.plugins_.FBComplete.prototype.cnds.OnAPILoaded, fbInst);

        // the user isn't logged in to Facebook.

    }

    }, true);

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I do realize there is some cleaning up to do. Such as removing those multiple calls to facebooklogout..... But I don't see how that would be making the currentstatus variable both true and false at the same time. Anyone?

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