# Bring a Godot game

For a Godot game that already ships as a Web export on other web game portals. You keep the project; you enable the `zokogames` addon, switch the export's HTML shell and replace the portal calls. The full reference is the [Godot engine page](https://docs.zokogames.com/engines/godot), which also covers [Godot 3](https://docs.zokogames.com/engines/godot#godot-3). The overall route is in [bring your game](https://docs.zokogames.com/porting/overview).

## 1. Export settings

Copy `addons/zokogames` into `res://addons/` and enable **ZokoGames** under **Project > Project Settings > Plugins**, as in [Godot: install](https://docs.zokogames.com/engines/godot#install). Then check the Web export preset:

| Setting | On ZokoGames |
| --- | --- |
| **Custom HTML Shell** | `res://addons/zokogames/export/zokogames_shell.html`. It loads the SDK before the engine and defines the bridge the autoload talks to. If your old shell held another portal's script, replace it; with a shell of your own, copy the bridge block across. |
| **Thread Support** | Off. The portal frame is not cross-origin isolated, so a threaded export does not start. Godot 4.3 and later export single-threaded by default. |
| File names | Keep `index.html`, `index.js`, `index.wasm`, `index.pck` as exported. Do not rename them to `.br` or `.gz`: Godot requests the plain names. |
| Texture compression | VRAM compression for desktop and mobile, so every browser has a format. |
| Stretch | **Stretch Mode** `canvas_items` with aspect `expand` or `keep`: the frame changes size with fullscreen and rotation. |
| Export With Debug | Off. |

Details: [web export settings that matter](https://docs.zokogames.com/engines/godot#web-export-settings-that-matter).

## 2. Replace the platform calls

Remove the other portal's shell code, scripts and autoloads first. Then `await ZokoGames.init_async()` once at startup and map each call:

| Your game does | With the `ZokoGames` autoload |
| --- | --- |
| Start the SDK | `await ZokoGames.init_async()`; `ZokoGames.is_available()` is false when the SDK is `disabled`, and the game must still run. |
| Loading finished | Nothing to write for the engine download: the shell sends `loadingStart` and `loadingStop` once the engine has started. For a longer loading screen of your own call `ZokoGames.loading_start()`, `loading_progress(percent)` and `loading_stop()`. |
| Gameplay start and stop | `ZokoGames.gameplay_start()` and `gameplay_stop()`. |
| Midgame ad (an interstitial or commercial break) | `await ZokoGames.request_ad_async("midgame")`. It completes after the ad is over, whatever the outcome. |
| Rewarded ad | `await ZokoGames.request_ad_async("rewarded")`; grant the reward only when the result's `ok` is true. |
| Pause and mute during ads | Nothing to write: the addon pauses the tree and mutes Master from `ad_started` until `ad_finished` or `ad_error`, and follows the portal's mute setting. Nodes that must keep running need the **Always** process mode. |
| Cloud save | `ZokoGames.data_set_item(key, value)` and `data_get_item(key, default)`, synchronous Strings. |
| Leaderboard score | `await ZokoGames.submit_score_async(encrypted_score, score)` for a signed-in player, on a board created in the console. No wrapper builds the encrypted payload; see [leaderboards](https://docs.zokogames.com/sdk/leaderboards#client-submission). |
| Purchases | `store_get_catalog_items_async`, `store_buy_item_async(item_id)`, `store_consume_item_async(sku, qty)`. Purchases are test purchases for now ([purchases](https://docs.zokogames.com/sdk/purchases)). |
| Sign-in prompt, player | `await ZokoGames.show_auth_prompt_async()`, `await ZokoGames.get_user_async()`. |

A complete script with init, both ads, save and score is in [a working script](https://docs.zokogames.com/engines/godot#a-working-script); every call is in [how calls work](https://docs.zokogames.com/engines/godot#how-calls-work). Godot's own `user://` files live in the browser's IndexedDB and stay on one device; move progress you want kept into `data_set_item`.

The [compatibility shim](https://docs.zokogames.com/guides/migrating#two-ways-to-port) is for JavaScript call sites only. A Godot game calls the autoload from GDScript, so it does not need the shim.

## 3. Build size and mobile

- Budget: 1,500 files, 250 MB unpacked, about 50 MB initial download (20 MB for mobile), estimated from uncompressed sizes. Keep the `.wasm` and `.pck` small.
- A custom export template with unused modules disabled cuts the engine itself.
- Load later levels after the first scene with `ResourceLoader.load_threaded_request`, which still works in a non-threaded export.
- Cap the resolution on phones and start audio from a "click to play" screen; see [mobile](https://docs.zokogames.com/guides/mobile).

## 4. Test before you submit

1. **In the editor** the simulator answers (`ZokoGames.is_simulated`). Its settings are under **Project Settings > zokogames/simulator**: ad fill, no fill and error, an ad blocker, a logged-out player, a disabled SDK.
2. **The Web export on `localhost`** (a local web server, not a file opened from disk) runs the SDK's local mode, which also enforces the three-minute midgame cooldown the simulator skips. See [Godot: test locally](https://docs.zokogames.com/engines/godot#test-locally).
3. **Upload the zip** (export folder contents, `index.html` at the archive root) and open the game's **Preview and QA** tab in the developer console to run the build in the portal frame with ads on ([build preview](https://docs.zokogames.com/getting-started/local-testing#the-build-preview-in-the-console)).

## Checklist

- [ ] Addon enabled; custom HTML shell set; the other portal's shell code and scripts removed.
- [ ] Thread Support off; file names as exported.
- [ ] `init_async` first; the game plays when `is_available()` is false.
- [ ] Gameplay start and stop at the right moments.
- [ ] Rewards only when the rewarded ad finished; your own nodes behave while the tree is paused.
- [ ] Saves through `data_set_item`; scores on a board created in the console.
- [ ] Other portal's logos, links and sitelock removed.
- [ ] Tested on `localhost` and in **Preview and QA**.

## Next

- Full reference: [Godot](https://docs.zokogames.com/engines/godot).
- Before upload: [build validation](https://docs.zokogames.com/requirements/build-validation) and the [launch checklist](https://docs.zokogames.com/requirements/checklist).
- Upload and publish: [submission walkthrough](https://docs.zokogames.com/getting-started/submission-walkthrough).
