Comparing value in another script

0 favourites
  • 8 posts
  • I've been trying for a while now to get the fgl api working in a plugin to use it in games. The new version adds a variable to check if Cross-Promotion is allowed by the host, which I am trying to implement as a condition.

    Cnds.prototype.FGLEnabled = function()

    {

         return fgl.crossPromotionEnabled;

    };

    As far as I can tell, this should work. However the event ends up firing whether or not the variable is true.

    doing console.log(fgl); shows that the object does have the property 'crossPromotionEnabled' and it's true/false at the correct time. But fgl.crossPromotionEnabled just returns undefined.

    I've compared the value in a c2 unrelated script and it works perfectly fine too. It seems to only be in the condition function that it wont work.

    Is this an engine limitation, or am I that bad at programming?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Im not too sure on this, but perhaps you need to pass the data along to the function

    like this:

    Cnds.prototype.FGLEnabled = function(DATA)

    {

         return fgl.crossPromotionEnabled;

    };

    Probably something like:

    Cnds.prototype.FGLEnabled = function(fgl)

    {

         return fgl.crossPromotionEnabled;

    };

    Not 100% sure, but its the first that popped to mind.

  • The most likely thing is you just made a typo and it's accessing a non-existent property, which returns undefined. Alternatively maybe it's not actually a boolean, and returns an object or some status in a string that is not a boolean. It depends on the API. There are hundreds of conditions that look like that in the C2 engine, and they all work correctly, so it must be something to do with the FGL API.

  • Given the documentation, it seems to be a boolean. But where did you declared fgl in your runtime code?

  • Ashley I've narrowed it down and it doesn't work when minified. This doesn't make much sense though since all I'm doing is referencing a variable in a different unminified file. When minified, fgl is an object, and fgl.crossPromotionEnabled is undefined. When unminified, fgl is the same object but fgl.crossPromotionenabled is a boolean as it should be. Is there any way to fix this?

  • fgl["crossPromotionEnabled"] ?

  • Yeah, see the section on Closure Compiler compatibility in the SDK docs.

  • septeven Ashley thanks :D Everything is working great now.

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