Skip to content

Skills: stop showing the global game in code a reader copies - #1735

Merged
obiot merged 1 commit into
masterfrom
docs/skills-no-global-game
Oct 12, 2026
Merged

obiot merged 1 commit into
masterfrom
docs/skills-no-global-game

Conversation

@obiot

@obiot obiot commented Oct 12, 2026

Copy link
Copy Markdown
Member

game is not deprecated. It is a documented export, assigned by setDefaultGame(this) at the end of Application.init(), which makes it whichever Application finished initializing last. That is unambiguous with one app and fine to have. What is not fine is a skill writing it, because then a reader copies a dependency on that.

An audit of all 23 skills found three places.

The real one

melonjs-effects-and-shaders wrote this four times:

game.viewport.addPostEffect(new BloomEffect(app.renderer));

It is holding app on the same line and still reaching for the global to get the viewport. Now app.viewport.

A factual slip

The glTF options table listed onLoaded as defaulting to app.onLevelLoaded. There is no global app, and the engine's default is game.onLevelLoaded (level.js:275). Corrected.

Two accurate facts missing their other half

melonjs-3d-assets and melonjs-tilemaps both document container as defaulting to game.world. I checked rather than assumed, and it is true: level.load assigns game.world, game.onLevelLoaded and game.mergeGroup as its defaults (level.js:271-277).

So the fact stays. What was missing is that a reader seeing "default: game.world" reasonably concludes relying on it is the intended path. Both pages now say what that default resolves to and show the alternative at the point of contact:

Those game. defaults are the engine's, not a recommendation. game is whichever Application finished init() last, so pass container explicitly from a Stage, where the right one is in your hand.

level.load("sceneId", { container: this.app.world, scale: 40 });

After

No skill shows the global in a code block, and none imports it. Verified by extracting every fenced block across all 23 skills and grepping them, rather than grepping the files as a whole, since the remaining matches are prose describing the defaults above.

Docs only, no engine change, so no CHANGELOG entry.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t

`game` is not deprecated, but it is whichever `Application` finished
`init()` last, so a skill that writes it is teaching a reader to depend
on that. An audit of all 23 skills found three places.

The effects skill was the real one. It wrote

    game.viewport.addPostEffect(new BloomEffect(app.renderer));

four times, reaching for the global for the viewport while holding
`app` on the same line. Now `app.viewport`.

The glTF options table listed `onLoaded` as defaulting to
`app.onLevelLoaded`. There is no global `app`, and the engine's default
is `game.onLevelLoaded` (`level.js:275`). Corrected.

The glTF and tilemap skills both document `container` as defaulting to
`game.world`, which is accurate: `level.load` really does assign
`game.world`, `game.onLevelLoaded` and `game.mergeGroup` as its
defaults. The fact stays, with the half that was missing. A reader who
sees "default: `game.world`" reasonably concludes relying on it is the
intended path, so both now say what that default actually resolves to
and show passing `container: this.app.world` from a `Stage`.

No skill shows the global in a code block any more, and none imports it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t
@obiot
obiot merged commit baaf32c into master Oct 12, 2026
8 of 9 checks passed
@obiot
obiot deleted the docs/skills-no-global-game branch October 12, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant