[Plugin] Call Javascript

0 favourites
From the Asset Store
Voice call plugin based on webrtc protocol for construct 3
  • Thank you.

    I've solved my problem.

    I call my function after system is loaded by using timeout.

  • if you can't get calljs to work on cocoonjs (and probably direct canvas also), open plugin's runtime.js file and edit it around line 49:

    change this:

    this.nameOfExternalScript = this.properties[0];

              this.returnValue= "";

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

              myScriptTag.setAttribute("type","text/javascript");

              myScriptTag.setAttribute("src", this.nameOfExternalScript);

              

              if (typeof myScriptTag != "undefined")

                   document.getElementsByTagName("head")[0].appendChild(myScriptTag);

    to this:

    if (typeof this.properties[0] != "undefined" && this.properties[0] != "") {

    this.nameOfExternalScript = this.properties[0];

              this.returnValue= "";

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

              myScriptTag.setAttribute("type","text/javascript");

              myScriptTag.setAttribute("src", this.nameOfExternalScript);

              

              if (typeof myScriptTag != "undefined")

                   document.getElementsByTagName("head")[0].appendChild(myScriptTag);

    }

    and it should work, but remember to clear the plugin's Scriptfile property (it must be empty for it to work with cocoonjs). this change should be done in original plugin also to prevent creating empty <script> tag.

    hope I helped anyone :)

  • can calljs work when exported to exe?

    Also can we include external apis? For example if I have an api that does something can I still write a js file that accesses that api?

    Thanks

  • I haven't looked at it yet, I'm on my iPad. Is it possible to return values to a construct2 variable? If I were to use this to fetch data from say Facebook, how do I then get the returned info into a usable construct variable?

    Thanks

  • I all,

    Thank you very mutch for the plugin.

    But I think there's a small "issue".

    I would like to pass a construct2 variable parameter to the fonction I call.

    Exemple for the demo file :

    Instead of doing sum(12,13), if I would like to make sum(x,y), x and Y are construct 2 variables. How should I do that.

    If I put a variable in construct 2 and I make Execute sum(X,Y, it doesn't seems to work.

    It acts as if it pass variables to javascript without affecting X and Y construct2 variables.

    Sorry for my poor english.

    I hope it will be well understanding.

    If someone has a solution, it will be greatly appreciated.

    Kind regards !

    Thibaut

  • Thibaut

    Try FunctionExt, it works with official function plugin -- call official function defined at event sheet, do some actions, then get return value back.

  • Is there a way to use a global variable from the game with this code? For example, how do I alert my highScore var?

    Or do I have to use something else?

    I have got this plugin working, I just don't know how to do the above. Thanks

  • I have a problem with this plugin and i was wondering if somebody would be able to assist me.

    The problem is as follows. The plugin does something that causes data not to be loaded properly. Which means the game either never gets past the loading bar or never loads in all the objects and just some. Also any of the javascript code stops working because of it.

    Quick note on this to, you dont actually have to call the plugin anywhere in the event sheets or use any of its functions to make it break loading in a few browsers.

    And this only happens on a few mobile phones (wp7 IE9 + android 4.0.4). Now is my question is there any way to fix this and if so what is the fix for this?

    I tried the change mentioned by ranma but it had no effect.

    Ignore the above.. i was so stupid to use console.log to test.. and completely forgot most modern mobiles do not support it in any way.. *sigh*

  • hi guys,

    I'm new to construct but I'm struggling using the this plugin.

    has anyone got an example of utilizing the external myjs file in ctx format.

    I'd appreciate it if anyone could help.

  • Joe7 I am starting to learn JavaScript and I habe this lame question:

    Can I use an external js library for USB communication ?

    I am playing with motors and controllers using USB port directly from web browser and it is working like a charm. Is it possible to send/receive data/text through USB using Construct or I'm dreaming to far?

  • Hi everyone!

    There's a lot of question here that wait for an answer and so i add mine:

    building my C2 project with eclipse + phonegap for android i found that calljs plugin added to LowLatencyAudio plugin works perfectly, but not in the case i make a "every x seconds" condition: execute "somewhat". This simply doesn't work on my device (samsung galaxy s2) and on other i try.

    so: is there anyone that could and would help me to find a way to solve my problem?

    Thank you very much!

    (sorry for my english)

  • Joe7, I can't seem to be able to downlad the plugin. Can anyone help?

  • Dasat

    The link is on this page

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • septeven, gotten. Thanks!!

  • Evening!

    Great plugin, just got it hooked up like a charm. Just wondering one thing though and this may be me being totally stupid, but I take it that we can't run this using preview mode?

    I mean, the project has to be exported every time we update anything such as event sheets on the capx?

    It got me wondering as I've been trying to get it working from the preview side, but wasn't sure if Construct has things in place that prevented one from doing so.

    (hopefully it's not too late to post on this thread!) :P

    Cheers!

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