# Defold

Defold's built-in HTML5 bundle runs on Wavedash with no extra tooling.

Source: https://docs.wavedash.com/engines/defold

<GithubLink href="https://github.com/wvdsh/examples/tree/main/example-defold" />
<PlaytestLink href="https://wavedash.com/playtest/defold-example/a8495ce5-748a-49dc-9515-aa7d3fff2e17" />

Defold exports to HTML5, producing a folder with `index.html`, a `.wasm` file, and your game data. This output works on Wavedash directly.

## Export your game

### Option A — Defold Editor

1. Open **Project > Bundle > HTML5 Application**
2. Choose a destination folder (e.g. `dist/`)
3. The output includes `index.html`, `dmloader.js`, your `.wasm` binary, and game archives

### Option B — bob.jar (command-line)

Download `bob.jar` from the [Defold releases](https://github.com/defold/defold/releases) and run:

```bash
java -jar bob.jar \
  --platform wasm-web \
  --archive \
  --bundle-output bundle \
  resolve build bundle
```

Then copy the output into your upload directory (e.g. `dist/`). The [example-defold](https://github.com/wvdsh/examples/tree/main/example-defold) repo includes a `build.sh` that does this automatically.

## SDK integration

Defold has a [full integration with the Wavedash SDK](https://github.com/wvdsh/sdk-defold), including Lua to JS bindings for easy scripting access to all of the Wavedash SDK functionality.

Open your Defold *game.project* file in the Defold Editor, select `Project` from the side menu, and in the `Dependencies` field add a new entry linking to a [Wavedash SDK for Defold release on GitHub](https://github.com/wvdsh/sdk-defold/releases). As an example, here's the link to the 1.0.0 release of the Wavedash SDK for Defold:

[`https://github.com/wvdsh/sdk-defold/archive/refs/tags/1.0.0.zip`](https://github.com/wvdsh/sdk-defold/archive/refs/tags/1.0.0.zip)

When the Wavedash SDK has been added as a project dependency all of the SDK functionality can be accessed from the `wavedash` module namespace.

<Urgent>
**Calling `wavedash.init()` is required.** Your game stays hidden behind the Wavedash loading screen until you do. Call it once your game is ready to play.
</Urgent>

```lua
function init(self)
    wavedash.init({}, function(_, event, payload)
        -- handle wavedash events here
    end)
end
```

## Initialization

Loading progress will be automatically updated as your game loads and will be at 100% when the Defold engine initializes and is ready to show your game content. Call `wavedash.init()` to dismiss the Wavedash loading screen:

```lua
function init(self)
    -- ... set up your game ...
    wavedash.init({}, function(_, event, payload)
        -- handle wavedash events here
    end)
end
```

## Configure wavedash.toml

Point `upload_dir` at the folder you bundled the HTML5 build to. Defold's bundle already includes `index.html` at the root, so `entrypoint` can be omitted.

```toml
game_id = "YOUR_GAME_ID_HERE"
upload_dir = "./dist"
```

<Note>
Defold reserves the top-level `build/` directory for its internal build cache. Use a different name like `dist/` for your upload directory.
</Note>
