Razorbill
Components

Script Component

ScriptComponent

Holds references to script assets attached to an entity. Each script runs its OnStart, OnUpdate, and OnDestroy lifecycle functions.

PropertyTypeDefaultDescription
scriptsArray<Guid>[]List of script asset GUIDs attached to this entity
propertiesJSONnullPer-instance script properties (key-value pairs accessible via get_script_property)

Attaching Scripts

Use the AttachScript operation:

{
  "op": "AttachScript",
  "params": {
    "entity_name": "Player",
    "script_name": "PlayerController"
  }
}

Or by GUID:

{
  "op": "AttachScript",
  "params": {
    "entity_guid": "a1b2c3d4-...",
    "script_guid": "e5f6a7b8-..."
  }
}

Per-Instance Properties

The properties field lets you configure script behavior per entity without modifying the script code:

{
  "op": "AddComponent",
  "params": {
    "entity_name": "EnemyA",
    "component_type": "ScriptComponent",
    "data": {
      "scripts": ["<patrol-script-guid>"],
      "properties": {
        "<patrol-script-guid>": {
          "patrol_speed": 3.0,
          "patrol_radius": 10.0
        }
      }
    }
  }
}

Access properties in scripts:

void OnStart(ScriptContext* ctx) {
    const char* speed_str = ctx->get_script_property(ctx, "patrol_speed");
    if (speed_str) {
        patrol_speed = atof(speed_str);
    }
}

Multiple Scripts

An entity can have multiple scripts. They execute in the order they appear in the scripts array:

{
  "scripts": [
    "<movement-script-guid>",
    "<health-script-guid>",
    "<ui-updater-script-guid>"
  ]
}

Detaching Scripts

{
  "op": "DetachScript",
  "params": {
    "entity_name": "Player",
    "script_name": "OldScript"
  }
}

On this page