How do I call an external file.js inside my plugin's runtime?

  • Hi devs :D, I'm trying to build a plugin for Facebook InstantGame, I used the Construct sdk to build my own, but I'm heavily stuck on the step when calling the Facebook SDK inside my runtime js, the Export always give me the error unable to run the script manifier when the option manify script is active, here is my code where I called the Facebook SDK:

    typeProto.onCreate = function()

    {

    var that=this;

    var script = document.createElement('script');

    script.src = "https://connect.facebook.net/en_US/fbinstant.6.3.js";

    document.getElementsByTagName('head')[0].appendChild(script);

    script.onload = function() {

    alert("Echopros!! Script loaded and ready");

    FBInstant.initializeAsync()

    .then(function() {

    console.log("Echopros 1");

    FBInstant.setLoadingProgress(100);

    FBInstant.startGameAsync()

    .then(function() {

    this2.runtime.trigger(cr.plugins_.FbInstant.prototype.cnds.entrypointComplete, this2);

    console.log("Echopros 2");

    contextId = FBInstant.context.getID();

    contextType = FBInstant.context.getType();

    var playerName = FBInstant.player.getName();

    var playerPic = FBInstant.player.getPhoto();

    var playerId = FBInstant.player.getID();

    entryPointData = FBInstant.getEntryPointData();

    console.log(playerId);

    console.log("Echopros 3");

    console.log(entryPointData);

    console.log(playerPic);

    console.log("Echopros 4");

    console.log(playerPic);

    // Once startGameAsync() resolves it also means the loading view has

    // been removed and the user can see the game viewport

    game.start();

    });

    });

    };

    };

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't think people are making C2 addons any more.

    I would suggest finding a similar addon that uses an external JS script, and check how it's done there.

    By the way, I've seen C2 addon for Facebook Instant Games, but I don't have a link, try searching the forum.

  • I don't think people are making C2 addons any more.

    I would suggest finding a similar addon that uses an external JS script, and check how it's done there.

    By the way, I've seen C2 addon for Facebook Instant Games, but I don't have a link, try searching the forum.

    thank you Dear, the link for the C2 Addon you mentioned was broken (https://www.construct.net/en/forum/construct-3/general-discussion-7/fb-instant-games-leaderboard-133334), I really got the way to call it correctly, but always the same problem while exporting the game "Script Manifier Error", really so appreciated for the reply :), thank you very much,

  • There is a paid addon:

    https://www.construct.net/en/forum/extending-construct-2/addons-29/facebook-instant-games-135414

    Unfortunately, I've just purchased it, he has the same problem, he couldn't call the sdk in the runtime file as I did, I don't know if there is a possibilty for the refund :(

  • You should contact the author, if he doesn't reply, then try Scirra support.

  • Thank you very much, great guiding :)

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