You need a code editor, such as Visual Studio Code, to write and edit your script. This document takes Visual Studio Code as an example.
- Download Visual Studio Code.
- Specify the external code editor as Visual Studio Code in Studio Preference.
- Find Code in the folder where the Visual Studio Code is located and open it. Now Studio is integrated with the code editor.
- Open any space in YAHAHA Desktop.
- In the scene, choose the object that you want to write scripts for and click the More button on the upper right corner.
- Go to the Gameplay tab and click the drop-down arrow on the +Component button. You can either upload your local script by choosing Upload local script or create a script from scratch by choosing Add Script.
- Click the edit button to edit your script in your code editor.
- Download the debugger
- Install the VS Code debugger by choosing … > Install from VSIX and opening the VSIX file you you just downloaded.
- Open the folder where the lua scripts are located.
- Create a launch.json file in Run and Debug.
- Copy the following JSON over to the file you just created.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ```
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: Debugging in Visual Studio Code
“name”: “Yahaha Lua Debugger”,
- Run the debugger to connect to YAHAHA Studio.
- Now you’ve successfully run the debugger and try to set a breakpoint in your script. YAHAHA Studio will connect to the debugger in Play mode.