Skip to content

How to start coding

Integrating with a code editor

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.

  1. Download Visual Studio Code.

  2. Specify the external code editor as Visual Studio Code in Studio Preference.

    itegrating-with-a-code-editor-1

  3. Find Code in the folder where the Visual Studio Code is located and open it. Now Studio is integrated with the code editor.

Creating or adding scripts

  1. Open any space in YAHAHA Desktop.
  2. In the scene, choose the object that you want to write scripts for and click the More button on the upper right corner.
  3. 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.

    Add script

  4. Click the edit button to edit your script in your code editor.

    Open script

Installing the YAHAHA Lua debugger

  1. Download the debugger
  2. Install the VS Code debugger by choosing ... > Install from VSIX and opening the VSIX file you you just downloaded.

    installing-the-yahaha-lua-debugger-1

Configuring the YAHAHA Lua debugger

  1. Open the folder where the lua scripts are located.

  2. Create a launch.json file in Run and Debug.

    configuring-the-yahaha-lua-debugger-2

  3. 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: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "yahaha_lua_mobdebug",
            "request": "attach",
            "name": "Yahaha Lua Debugger",
            "basedir": "${workspaceFolder}",
            "host": "127.0.0.1",
            "port": 8172,
            "lua-extension": [
                ".lua",
                ".lua.txt",
                ".lua.bytes"
            ]
        }
    ]
    }
    
  4. Run the debugger to connect to YAHAHA Studio.

    configuring-the-yahaha-lua-debugger-3

  5. 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.

    configuring-the-yahaha-lua-debugger-4