1. Hey! Guest! The 33rd GMC Jam will take place between May 23rd, 12:00 UTC (Friday noon) and May 27th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GML [SOLVED] Is it possible to execute javascript dynamically through GML?

Discussion in 'Programming' started by Xalezar, May 16, 2019 at 4:02 AM.

Tags:
  1. Xalezar

    Xalezar Member

    Joined:
    Jul 27, 2018
    Posts:
    6
    For example, say when the player clicks on a button in my HTML5 game, is it possible to execute a javascript function at that point in time?
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    3,960
    You can implement that as an extension. Create an extension, add a JS file to it, then put this inside the file:
    Code:
    function myfunc() {
      /* Your code here */
    }
    
    Then double-click on the file in the IDE (not in explorer), add a function to it by the same name, and specify the argument count accordingly. Then you can call the JS code from GML using the same name.
     
    Japster and Amon like this.
  3. Xalezar

    Xalezar Member

    Joined:
    Jul 27, 2018
    Posts:
    6
    Perfect, thanks!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice