GameMaker API Reference
This document provides an exhaustive, meticulous reference for every macro, global setting, state variable, method, and lifecycle event included in the LogLudo GameMaker SDK.
Global Macros & Settings
Section titled “Global Macros & Settings”#macro LOGLUDO
Section titled “#macro LOGLUDO”A shorthand macro aliasing global.logludo_sdk. Allows accessing the SDK methods and state from any script or object without referencing the global. prefix.
#macro LOGLUDO global.logludo_sdkglobal.logludo_settings
Section titled “global.logludo_settings”Configuration struct defined in scr_LOGLUDO.gml. Configured once per project.
| Property | Type | Description |
|---|---|---|
api_url |
String | The base endpoint for the LogLudo API. Default: "https://api.logludo.com/v0". |
game_ID |
String | Your project’s unique UUID obtained from the LogLudo dashboard. |
global.logludo_settings = { api_url: "https://api.logludo.com/v0", game_ID: "9d3135a3-09a8-4bef-a855-41e5e677a8e4"};State Variables (LOGLUDO)
Section titled “State Variables (LOGLUDO)”The LOGLUDO struct maintains internal counters, queues, and network state:
| Property | Type | Description |
|---|---|---|
session_id |
String | Unique session identifier generated at boot ("sess_<unix>_<timer>"). |
is_first_session_today |
Boolean | true if this is the player’s first session on the current calendar date (YYYY-M-D). |
bucket |
Real | Cohort A/B test bucket (integer 1..10), assigned once per device and persisted in logludo_device.json. |
days_since_install |
Real | Number of complete days elapsed since first_open_date. |
session_count |
Real | Total number of lifetime game sessions started on this device. |
active_mask |
Real | 32-bit integer bitmask tracking active days across the first 30 days of installation. |
first_open_date |
Real | Unix epoch timestamp (seconds) of the game’s very first launch. |
event_buffer |
Array | In-memory queue of pending events waiting to be flushed. |
pending_batch |
Array | Temporary slice of up to 50 events currently in flight over HTTP. |
batch_limit |
Real | Buffer size threshold that triggers an automatic flush (default: 10). |
request_id |
Real | Async HTTP request handle returned by http_request(). Set to -1 when no batch request is active. |
capture_request_id |
Real | Async HTTP request handle for room capture uploads. Set to -1 when idle. |
events_this_second |
Real | Rolling counter tracking event emissions within the current second. |
last_event_second |
Real | Second timestamp (current_time div 1000) for the rate limiter. |
last_flush_time |
Real | Timestamp (current_time) of the most recent HTTP flush attempt. |
tracked_paths |
Struct | Dictionary mapping stringified instance IDs to active motion path history trackers. |
_aggregates |
Struct | Dictionary storing active in-memory metric accumulators (sum, average, frequency). |
Methods & Functions
Section titled “Methods & Functions”LOGLUDO.send_action(_category, _action, _payload)
Section titled “LOGLUDO.send_action(_category, _action, _payload)”The recommended high-level method to record gameplay, progression, monetization, and system telemetry conforming to the LogLudo taxonomy.
Parameters
Section titled “Parameters”_category(String): One of the 8 standard categories:"session_start","session_end","progression","monetization","gameplay","design","performance","error"._action(String): Name of the event action (e.g.,"level_end","item_purchased")._payload(Struct, Optional): Custom metadata struct. If non-struct is provided, defaults to{}.
Returns: undefined
Section titled “Returns: undefined”LOGLUDO.send_action("progression", "checkpoint_reached", { checkpoint_id: 3, health: hp, track_id: id // Auto-populates scenelytics coordinates});LOGLUDO.send_event(_name, _payload)
Section titled “LOGLUDO.send_event(_name, _payload)”Dispatches a raw telemetry event into the internal buffer with rate limiting, deduplication, and spatial extraction.
Parameters
Section titled “Parameters”_name(String): Event category name._payload(Struct, Optional): Event payload.
Internal Mechanics:
Section titled “Internal Mechanics:”- Rate Limiting: Enforces a 20 event/second cap for non-critical events.
- Buffer Cap: Drops non-critical events if
event_bufferhas $\ge 150$ items. - Spatial Normalization: Extracts
x,y,endX,endY, ortrack_id. Calculates offsets relative toobj_LOGLUDO.xandobj_LOGLUDO.y. Rounds coordinates to 2 decimal places. Auto-injectsroom_nameif missing. - Motion Trail Snapshot: If
track_idis tracked intracked_paths, clones a copy of the recent path history intoscenelytics.recent_path. - Deduplication: Compares against pending events in
event_bufferand drops exact duplicate payloads. - Flush Trigger: Initiates
flush_events()ifarray_length(event_buffer) >= batch_limit(10) or on development handshake.
Returns: undefined
Section titled “Returns: undefined”LOGLUDO.init()
Section titled “LOGLUDO.init()”Initializes the SDK session, loads offline events from disk, and calculates device cohort metrics.
Internal Mechanics:
Section titled “Internal Mechanics:”- Generates
session_idusinglogludo_get_unix_time()+get_timer(). - Restores unsent events from
logludo_offline.json. - Loads or creates
logludo_device.json. Validatesgame_idscope match. - Increments
session_count. Computesdays_since_installand updatesactive_mask. - Writes updated device data back to
logludo_device.json.
Returns: undefined
Section titled “Returns: undefined”LOGLUDO.flush_events()
Section titled “LOGLUDO.flush_events()”Immediately bundles pending events in event_buffer into an HTTP POST request.
Internal Mechanics:
Section titled “Internal Mechanics:”- Slices up to 50 events (
min(array_length(event_buffer), 50)) intopending_batch. - Serializes
pending_batchto a JSON string. - Sends HTTP POST with header
Content-Type: application/jsontoglobal.logludo_settings.api_url. - Stores the returned request handle in
LOGLUDO.request_id.
Returns: undefined
Section titled “Returns: undefined”LOGLUDO.clear_pending()
Section titled “LOGLUDO.clear_pending()”Called automatically when the async HTTP response confirms successful receipt (HTTP 200–299) of a batch.
Internal Mechanics:
Section titled “Internal Mechanics:”- Removes the delivered batch slice from
event_buffer(array_delete(event_buffer, 0, array_length(pending_batch))). - Clears
pending_batch = []. - Unlocks the network handle (
request_id = -1). - Updates
logludo_offline.jsonwith the remaining buffer. - If the remaining buffer still has $\ge 10$ events, immediately triggers another
flush_events().
Returns: undefined
Section titled “Returns: undefined”LOGLUDO.save_offline()
Section titled “LOGLUDO.save_offline()”Persists the current in-memory event_buffer array to logludo_offline.json using json_stringify().
Returns: undefined
Section titled “Returns: undefined”LOGLUDO.track_path(_inst, _max_length = 60)
Section titled “LOGLUDO.track_path(_inst, _max_length = 60)”Registers an instance ID for continuous frame-by-frame coordinate tracking in Step_0.
Parameters
Section titled “Parameters”_inst(Id.Instance): The GameMaker instance to track._max_length(Real, Optional): Maximum coordinate points to retain in rolling memory (default:60, which is 1 second at 60 FPS).
LOGLUDO.track_path(obj_player.id, 120);Returns: undefined
Section titled “Returns: undefined”LOGLUDO.stop_tracking_path(_inst)
Section titled “LOGLUDO.stop_tracking_path(_inst)”Removes the specified instance from tracked_paths.
Parameters
Section titled “Parameters”_inst(Id.Instance): The GameMaker instance to stop tracking.
Returns: undefined
Section titled “Returns: undefined”LOGLUDO.aggregate_add(_name, _value, _type = "sum")
Section titled “LOGLUDO.aggregate_add(_name, _value, _type = "sum")”Accumulates high-frequency metrics in client memory without firing network requests.
Parameters
Section titled “Parameters”_name(String): Unique identifier for the aggregator._value(Real or String): The value to add or record._type(String, Optional): Aggregator type:"sum"(Default): Increments running total (value += _value)."average": Tracks running sum and sample count (sum += _value,count += 1)."frequency": Tallies frequency count in a map (map[string(_value)] += 1).
LOGLUDO.aggregate_add("gold_collected", 25, "sum");LOGLUDO.aggregate_add("boss_hit_damage", 120, "average");LOGLUDO.aggregate_add("weapons_selected", "flamethrower", "frequency");Returns: undefined
Section titled “Returns: undefined”LOGLUDO.aggregate_pop(_name)
Section titled “LOGLUDO.aggregate_pop(_name)”Computes the final aggregate metric, removes the accumulator from memory, and returns the result.
Parameters
Section titled “Parameters”_name(String): Unique identifier for the aggregator.
Returns:
Section titled “Returns:”- For
"sum": Real number. - For
"average": Real number (count > 0 ? (sum / count) : 0). - For
"frequency": Sorted array of top 10 structs[{ item: String, count: Real }]. - If the aggregator does not exist:
undefined.
var _stats = { total_gold: LOGLUDO.aggregate_pop("gold_collected"), avg_damage: LOGLUDO.aggregate_pop("boss_hit_damage"), fav_weapons: LOGLUDO.aggregate_pop("weapons_selected")};LOGLUDO.send_action("progression", "level_end", _stats);LOGLUDO.send_room_capture(_room_name, _base64_data)
Section titled “LOGLUDO.send_room_capture(_room_name, _base64_data)”Uploads a base64-encoded PNG image of a room layout to the /capture endpoint.
Parameters
Section titled “Parameters”_room_name(String): Name of the room (e.g.room_get_name(room))._base64_data(String): Base64 string containing PNG image bytes.
LOGLUDO.send_room_capture_tile(_room_name, _base64_data, _tx, _ty)
Section titled “LOGLUDO.send_room_capture_tile(_room_name, _base64_data, _tx, _ty)”Uploads a single 3000px tile chunk of a large room layout to the /capture endpoint.
Parameters
Section titled “Parameters”_room_name(String): Name of the room._base64_data(String): Base64 string containing PNG image bytes for this tile._tx(Real): Tile horizontal column index (0-indexed)._ty(Real): Tile vertical row index (0-indexed).
LOGLUDO.send_room_manifest(_room_name, _width, _height, _tileSize, _cols, _rows)
Section titled “LOGLUDO.send_room_manifest(_room_name, _width, _height, _tileSize, _cols, _rows)”Uploads the room dimension and grid manifest JSON to /capture so the LogLudo dashboard can assemble the tiles into a seamless zoomable map.
Parameters
Section titled “Parameters”_room_name(String): Name of the room._width(Real): Full room width in pixels._height(Real): Full room height in pixels._tileSize(Real): Pixel dimension per tile (default:3000)._cols(Real): Number of horizontal tile columns._rows(Real): Number of vertical tile rows.
logludo_get_unix_time()
Section titled “logludo_get_unix_time()”Standalone global helper function that calculates the current Unix epoch timestamp in seconds without altering or corrupting the host developer’s timezone settings.
Internal Mechanics:
Section titled “Internal Mechanics:”- Saves developer’s current timezone (
date_get_timezone()). - Temporarily switches timezone to
timezone_utc. - Computes seconds elapsed between Unix epoch (
25569in GameMaker datetime) anddate_current_datetime(). - Restores original timezone and returns the Unix integer.
Returns: Real (Unix epoch seconds)
Section titled “Returns: Real (Unix epoch seconds)”Global Handlers & Timers
Section titled “Global Handlers & Timers”exception_unhandled_handler(ex)
Section titled “exception_unhandled_handler(ex)”Global crash catcher initialized automatically at script parse time. Traps unhandled GameMaker exceptions to logludo_crash.json with severity "fatal_crash", error message, call stack, and current room name before halting.
_logludo_init (Time Source)
Section titled “_logludo_init (Time Source)”One-shot time_source that executes after 1 frame on time_source_global. Instantiates obj_LOGLUDO if not already present.
_logludo_save (Time Source)
Section titled “_logludo_save (Time Source)”Repeating time_source that fires every 5 seconds on time_source_global, calling LOGLUDO.save_offline().
Controller Object: obj_LOGLUDO
Section titled “Controller Object: obj_LOGLUDO”obj_LOGLUDO is the persistent singleton controller managing game-loop hooks:
Events & Behaviors
Section titled “Events & Behaviors”| Event | Code File | Purpose & Responsibilities |
|---|---|---|
Create_0 |
Create_0.gml |
Enforces singleton uniqueness (instance_number > 1 -> instance_destroy()). Calls LOGLUDO.init(). Checks and uploads pending crash reports (logludo_crash.json). Queries OS and GPU info via os_get_info() (safely frees map). Dispatches session_start event with cohort metrics. |
Step_0 |
Step_0.gml |
Runs the dev auto-capture state machine (listens for "capture" keyword and tiles rooms). Sends room performance ping after 10s (average_fps: round(fps_real)). Updates coordinate history for tracked_paths. Flushes buffer if idle for 60s. Detects os_is_paused() for mobile backgrounding. |
Other_3 (Game End) |
Other_3.gml |
Dispatches session_end with session duration in seconds. Saves buffer to disk and triggers immediate network flush before process death. |
Other_4 (Room Start) |
Other_4.gml |
Snaps x = 0; y = 0; to serve as the immutable origin anchor for Scenelytics calculations. |
Other_62 (Async HTTP) |
Other_62.gml |
Inspects HTTP response async_load[? "http_status"]. Calls LOGLUDO.clear_pending() on HTTP 200–299. Unlocks request_id = -1 on network error to allow retry on next flush. |
Other_63 (Async Dialog) |
Other_63.gml |
Receives async input from get_integer_async for the developer SceneLytics room capture prompt (1: capture, 2: skip, 3: snooze for 1 week). |
Destroy_0 |
Destroy_0.gml |
Protected against unsafe auto-recreation loops. |