GameMaker Studio · GML · Downloadable content
gmda_syncContentKeys
Fetches an explicit set of content keys, emitting one content_loaded per key.
Signature
gmda_syncContentKeys(keys) -> realWhat it does
Iterates the keys (a comma-separated string is split first) and GETs /gamecontent/<key> with the session headers for each one. Each key arrives as its own content_loaded { success, response } event, with the event's tag field set to that key so you can tell them apart; response is the envelope { schema_version, generated_at, "<key>": <your value> }, so read your value at e.response[$ e.tag]. Nothing is cached on disk. This is the on-demand path: a master index can declare which keys exist, so the catalog grows without an app update. Returns 1 once the requests are dispatched, or 0 when there is no active session or keys is neither an array nor a string.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| keys | array | string | required | The content keys to fetch, regardless of their panel category: an array of strings, or a comma-separated string ("levels,packs"). |
How to call it
Call gmda_syncContentKeys with an array of keys (or a comma-separated string), then read each content_loaded event with gmda_pollEvent(), switching on the event's tag to route each key's payload.
Result event: content_loaded { success, response }
Example
gmda_syncContentKeys(["levels6", "styles_pack_3"]); // or gmda_syncContentKeys("levels6,styles_pack_3");
// in the Step event, drain the queue:
var e = gmda_pollEvent();
while (!is_undefined(e)) {
if (e.event == "content_loaded" && e.success) {
store_content(e.tag, e.response[$ e.tag]); // value at response[$ key]
}
e = gmda_pollEvent();
}Use cases
- Sync a specific batch of on-demand packs chosen from a master content index.
- Refresh just the keys a player unlocked, leaving the rest untouched.