Example of c2_callFunction

  • I am pretty new to Construct 2 but have used Javascript for years.

    I am having trouble finding a complete example of "c2_callFunction " showing how to use it, and where the Javascript code is located. (And I can't find an example because the dropbox examples return "the 404 file not found" error).

    Assuming I want to do some calculation on a variable "Variable_A" (passed from Construct 2) times 2, and then return the value to Construct 2 (and then use it somewhere - ie. place as value in text.)

    The equation would be X times 2 = 18 if "X" is "9"

    My questions are:

    1. Where do I write the Javascript function(ie. Where is the HTML file (name and location) ?

    2. How do I call the "c2_callFunction".

    3. How do I return the result.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use c2_callFunction is to call a C2 function from javascript

    Use Browser.execJs() to call a javascript function from c2. It just calls the javascript eval() function.

    1. Typically in a plugin, but you can put it anywhere you like.

    2. Just like in the manual. If the C2 function you want to call is named "foo", you'd call it with c2_callFunction("foo", []);

    3. Use the "set return value" in the "foo" function.

    You probably just want to use the Browser object to call javascript if i understand you correctly.

    Set variable_a to Browser.ExecJS(variable_a&"*2")

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