How do I pass a global Variable with Javascript?

0 favourites
  • 4 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.
  • Hi all

    in construct 3 im able to pass a global var in js using the following:

    rik.logError(runtime.globalVars.myGlobalVar);

    in c2 obviously i need to use the Browser.Execute Javascript object

    but what would the in parenthesis syntax be in c2?

    i have no issue making the call successfully, but when i do so im missing the content of my global var.

    p.s. - im able to pass a regular string successfully just dunno the format to send my globalVar

    thanks for the look.

    Rik

  • I am also interested in knowing how to do this in C2, (how to pass an in-game global variable using the execute JavaScript action?). Ashley can you confirm?

    Thanks in advanced.

  • There is no api to access global variables and such in c2 like there is in c3. Since we are dealing with JavaScript you can find a path to access the global but the minifier will break that.

    Generally you’d just covert the variable to a string when you use execjs.

    Browser.execjs("alert("&myglobal&")")

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • i was afraid this was going to be the answer, so i had an alternate solution in place that is similar to your suggestion.

    thanks for the assist -- VERY much appreciated!

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