how to create a Java script code in the game itself and use it?

0 favourites
  • 5 posts
From the Asset Store
Awardkit
$5 USD
Create custom awards and achievement or use the many templates and create your own.
  • how to create a Java script code in the game itself and use it?

    That is, write it directly in the game itself and use it?

  • You mean at runtime? Maybe with the browser object I guess?

    construct.net/en/make-games/manuals/construct-3/plugin-reference/browser

  • There's eval(), but it's generally regarded as unsafe and sometimes security measures block it from working.

    You can also load a new script file with dynamic content. As Construct uses modules, you can dynamic import a custom script like this:

    const scriptContent = `console.log("Hello world!");`;
    const scriptUrl = URL.createObjectURL(new Blob([scriptContent], { type: "text/javascript" }));
    await import(scriptUrl);
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There's eval(), but it's generally regarded as unsafe and sometimes security measures block it from working.

    You can also load a new script file with dynamic content. As Construct uses modules, you can dynamic import a custom script like this:

    > const scriptContent = `console.log("Hello world!");`;
    const scriptUrl = URL.createObjectURL(new Blob([scriptContent], { type: "text/javascript" }));
    await import(scriptUrl);
    

    I'm interested in this "eval()"

    Is it possible to make the command "eval(TextInput.Text)" in the game?

    I need to write text (code) in the game itself using TextInput and then when an event occurs, for example, “when a button is pressed,” perform a script action (eval(TextInput.Text))

    for example in the game there is sprite 1

    and in TextInput write script(sprite1.setOpacity(0.5))

    will it work?

    is there any source?

  • You mean at runtime? Maybe with the browser object I guess?

    https://www.construct.net/en/make-games/manuals/construct-3/plugin-reference/browser#internalH1Link0

    I don’t understand what the browser has to do with it

    I explained my thoughts in more detail in a previous post.

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