Skip to content
Dashboard

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.


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_sdk

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.
Example Configuration
global.logludo_settings = {
api_url: "https://api.logludo.com/v0",
game_ID: "9d3135a3-09a8-4bef-a855-41e5e677a8e4"
};

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).

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.

  • _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 {}.
Example Usage
LOGLUDO.send_action("progression", "checkpoint_reached", {
checkpoint_id: 3,
health: hp,
track_id: id // Auto-populates scenelytics coordinates
});

Dispatches a raw telemetry event into the internal buffer with rate limiting, deduplication, and spatial extraction.

  • _name (String): Event category name.
  • _payload (Struct, Optional): Event payload.
  1. Rate Limiting: Enforces a 20 event/second cap for non-critical events.
  2. Buffer Cap: Drops non-critical events if event_buffer has $\ge 150$ items.
  3. Spatial Normalization: Extracts x, y, endX, endY, or track_id. Calculates offsets relative to obj_LOGLUDO.x and obj_LOGLUDO.y. Rounds coordinates to 2 decimal places. Auto-injects room_name if missing.
  4. Motion Trail Snapshot: If track_id is tracked in tracked_paths, clones a copy of the recent path history into scenelytics.recent_path.
  5. Deduplication: Compares against pending events in event_buffer and drops exact duplicate payloads.
  6. Flush Trigger: Initiates flush_events() if array_length(event_buffer) >= batch_limit (10) or on development handshake.

Initializes the SDK session, loads offline events from disk, and calculates device cohort metrics.

  1. Generates session_id using logludo_get_unix_time() + get_timer().
  2. Restores unsent events from logludo_offline.json.
  3. Loads or creates logludo_device.json. Validates game_id scope match.
  4. Increments session_count. Computes days_since_install and updates active_mask.
  5. Writes updated device data back to logludo_device.json.

Immediately bundles pending events in event_buffer into an HTTP POST request.

  1. Slices up to 50 events (min(array_length(event_buffer), 50)) into pending_batch.
  2. Serializes pending_batch to a JSON string.
  3. Sends HTTP POST with header Content-Type: application/json to global.logludo_settings.api_url.
  4. Stores the returned request handle in LOGLUDO.request_id.

Called automatically when the async HTTP response confirms successful receipt (HTTP 200–299) of a batch.

  1. Removes the delivered batch slice from event_buffer (array_delete(event_buffer, 0, array_length(pending_batch))).
  2. Clears pending_batch = [].
  3. Unlocks the network handle (request_id = -1).
  4. Updates logludo_offline.json with the remaining buffer.
  5. If the remaining buffer still has $\ge 10$ events, immediately triggers another flush_events().

Persists the current in-memory event_buffer array to logludo_offline.json using json_stringify().


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.

  • _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).
Example: Track Player Motion for 2 Seconds
LOGLUDO.track_path(obj_player.id, 120);

Removes the specified instance from tracked_paths.

  • _inst (Id.Instance): The GameMaker instance to stop tracking.

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.

  • _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).
Examples
LOGLUDO.aggregate_add("gold_collected", 25, "sum");
LOGLUDO.aggregate_add("boss_hit_damage", 120, "average");
LOGLUDO.aggregate_add("weapons_selected", "flamethrower", "frequency");

Computes the final aggregate metric, removes the accumulator from memory, and returns the result.

  • _name (String): Unique identifier for the aggregator.
  • 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.
Example Usage
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.

  • _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.

  • _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.

  • _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.

Standalone global helper function that calculates the current Unix epoch timestamp in seconds without altering or corrupting the host developer’s timezone settings.

  1. Saves developer’s current timezone (date_get_timezone()).
  2. Temporarily switches timezone to timezone_utc.
  3. Computes seconds elapsed between Unix epoch (25569 in GameMaker datetime) and date_current_datetime().
  4. Restores original timezone and returns the Unix integer.

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.


One-shot time_source that executes after 1 frame on time_source_global. Instantiates obj_LOGLUDO if not already present.


Repeating time_source that fires every 5 seconds on time_source_global, calling LOGLUDO.save_offline().


obj_LOGLUDO is the persistent singleton controller managing game-loop hooks:

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.