Repository navigation
Skills: stop showing the global game in code a reader copies - #1735
Merged
Merged
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gameis not deprecated. It is a documented export, assigned bysetDefaultGame(this)at the end ofApplication.init(), which makes it whicheverApplicationfinished 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-shaderswrote this four times:It is holding
appon the same line and still reaching for the global to get the viewport. Nowapp.viewport.A factual slip
The glTF options table listed
onLoadedas defaulting toapp.onLevelLoaded. There is no globalapp, and the engine's default isgame.onLevelLoaded(level.js:275). Corrected.Two accurate facts missing their other half
melonjs-3d-assetsandmelonjs-tilemapsboth documentcontaineras defaulting togame.world. I checked rather than assumed, and it is true:level.loadassignsgame.world,game.onLevelLoadedandgame.mergeGroupas 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: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