idny99's Forum Posts

  • 4 posts
  • Bump

    Would it be better to write a plugin to handle this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi,

    I'm using the CallJS plugin presently to call functions I have in an external script in the following way:

    callJS: execute myFunction();[/code:38uehlgw]
    [i]myFunction is located in someScript.js[/i]
    
    This is currently working well, however I want to be able to pass in global variable as parameter like so:
    [code:38uehlgw]callJS: execute myFunction(someGlobalVariable);[/code:38uehlgw]
    
    The reason for this is I want to use the global variable in further scripts which eventually will be passed to my API so that I can store data and scores. How can I do this? 
    
    Any help will be much appreciated.
  • Thanks for the response. I have included the browser object but it is unable to execute a function located in the external Javascript file, it throws a referenceError undefined which makes sense as it's unable to locate the function.

    So I guess what I'm asking is how to call a function in an external file?

  • Hello,

    New here so sorry if my understand of C2 is limited.

    I have an external Javascript files located in the same directory as the exported index.html which I am using to store all the external functions required for the game. I am using CallJS plugin to interface with this external script which works well in other area of the game.

    My problem here is I would like to be able to execute a function in the external script (I assume using CallJS is best here) as soon as the game is loaded. As an example here is my function

    someScript.js
    
    var myObject = function() {
       function gameLoaded() { //this does not work
           //do something here as soon as game loaded
           console.log("game was loaded successfully");
       }
    }();[/code:lvtza9g3]
    
    I have attached this to the system.OnStartLayout event but when the game has loaded this function is not firing (I am using the console log to test this). 
    
    How can I get this to run on first load?
  • 4 posts