Javascript Templates

What do you mean by JavaScript template?

In my opinion, a JavaScript template would be a concise snippet of code, typically ranging from two to five lines, that utilizes commonly used functions. For instance, consider the following code snippet:

const threeCamera = runtimeScene.getLayer(‘’).getRenderer().getThreeCamera();
const threeScene = runtimeScene.getLayer(‘’).getRenderer().getThreeScene();

This snippet demonstrates how to access and retrieve specific properties from a scene.

Another example of advanced scene variable manipulation is shown below:

const variable = runtimeScene.getVariables.get(“variable”);
const variableJS = variable.getAsJSObject();

How it should be implemented

To implement this functionality, a small button should be placed in the top-right corner of a JavaScript code block. This button should allow users to select a template. If there is already code present within the JavaScript code block, the button should prompt the user to either replace the existing code, cancel the action, or add the selected template to the top of the code block.

2 Likes

@cokiesyum, you have submitted THE MOST feature requests BY FAR on this forum, and surprisingly, almost every single one is an amazing feature!

Keep up the good work!

As for my take, this would be super cool. As a person who has never used Javascript in GDevelop, having pre-made templates available might make me start using it!

2 Likes

Thank you so much! i try as hard as i can :))

1 Like