# 04 — Drag-and-Drop (DnD) Action Node Serialization

DnD = visual-scripting block system inside Object events. **Not** stored as GML strings on disk — serialized as discrete binary operational nodes inside the Object block of [03-gmd-format](03-gmd-format.md).

A decompiler must either:

- Re-render nodes into a visual GUI matrix (LateralGM approach), or
- Procedurally transcompile each node into equivalent GML source.

## Per-node binary layout

| Field | Type | Description |
|---|---|---|
| `Action_ID` | Int32 | Static ID mapping to a core engine action (e.g. "Move Free", "Create Instance") |
| `Applies_To` | Int32 | Scope: `-1` = self, `-2` = other, `>= 0` = specific Object ID |
| `Is_Relative` | Bool (1 byte) | Whether numeric values are absolute or delta to current state |
| `Arg_Count` | Int32 | Number of arguments following |
| `Argument_Types` | Int32[`Arg_Count`] | Type of each arg (String / Real / Resource ID / Bool) |
| `Argument_Values` | mixed bytes | Payload — strings null-terminated, numerics 8-byte doubles |

## Parsing approach

```
read Int32  -> action_id
read Int32  -> applies_to
read 1 byte -> is_relative
read Int32  -> arg_count
read arg_count * Int32 -> arg_types
for each type in arg_types:
    if String:    read until \0
    if Real:      read 8 bytes (double)
    if Resource:  read Int32
    if Bool:      read 1 byte
```

## Building an Action_ID table

The `Action_ID` integers are opaque without a lookup table mapping ID → engine function. LateralGM ships such a table for the supported versions; consult its source. Unknown IDs in 5.3a-specific blocks may need empirical reverse-engineering by IDE-side experimentation.

## GML transcompilation

Many DnD actions have a clean GML equivalent (e.g. "Move Free" → `motion_set(dir, speed)`). For event-recovery output that round-trips, prefer GML transcription over preserving DnD nodes — easier to diff in version control via [12-tool-gmksplitter](12-tool-gmksplitter.md) style trees.

## See also

- [03-gmd-format](03-gmd-format.md) — where DnD lives in the parent format
- [05-gml-vm](05-gml-vm.md) — execution target if transcompiling
- [07-gml-core-functions](07-gml-core-functions.md) — equivalents for common DnD actions
- [11-tool-lateralgm](11-tool-lateralgm.md) — reference parser
