Referencing C3's Global Variables in a custom JS file

1 favourites
  • 2 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hello,

    In my game, I'm using an exported GB Studio game inside of an iframe, as shown here:

    Subscribe to Construct videos now

    To achieve this, I just imported all gb studio generated files and imported them in the Files folder in the Project Manager (while redirecting everything to be outside of folders).

    This works fine, but I want to be able to get C3's variables from inside the Script.JS file. I've looked around, but I still can't quite grasp how to achieve that.

    I've tried creating a main.js file, and tried referencing it in the gb.html file, which loads the emulator, but since the Script.JS code is only called when the iframe is created, I get a "main.js:5 Uncaught ReferenceError: runOnStartup is not defined" error.

    Any help is appreciated!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry for the double post - I ended up figuring it out by using Query String values.

    So instead of calling the iframe to open "gb.html", I call it to open:

    "gb.html?game=" & gg_gamename
    

    Where gg_gamename is a variable that contains the rom name that I want the emulator to open. I plan to also add query strings for each button, so the player can use the same controls as C3 inside of the gb emulator.

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