Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/FarlandsModdingTeam/TerbinProyect/llms.txt

Use this file to discover all available pages before exploring further.

ServiceInstances is a static handler class decorated with [TerbinExecutable] attributes that routes IPC calls to Manager.Instances and Manager.Index. Every game instance is an isolated directory on disk containing a hidden .TerbinInstaceInformation folder that stores the instance manifest (ManifestInstance) and individual plugin manifests. The global index of all registered instances is tracked in a separate hidden JSON file managed by Manager.Index.

Data Models

ManifestInstance

The full, on-disk manifest for a single instance. Deserialized from the hidden information folder.
FieldTypeDescription
Namestring?Human-readable name of the instance.
Versionstring?Game version string (populated after CloneGame).
Executablestring?Relative path to the game executable inside the instance directory.
PluginsList<ReferencePlugin>Lightweight references to every installed plugin manifest.

ReferenceInstance

Lightweight index entry stored in the global index, used for listing without loading individual manifests.
FieldTypeDescription
Namestring?The instance name.
OutSidebool?Whether the instance directory lives outside the configured rute_instances path.
Pathstring?Absolute or relative path to the instance root directory.

ManifestInstanceDTO (wire format)

The serialized transport struct sent over IPC.
FieldTypeWire encoding
Namestring?Length-prefixed UTF-16 char array
Versionstring?Length-prefixed UTF-16 char array
PluginCountThreeQuartersIntFixed-size 3-byte integer

ReferenceInstanceDTO (wire format)

The serialized transport struct used in list responses.
FieldTypeWire encoding
Namestring?Length-prefixed UTF-16 char array
OutSidebool?sbyte (ToBoolUk)
Pathstring?Length-prefixed UTF-16 char array

Operations

Creates a new instance directory and registers it in the global index. The service calls Manager.Instances.NewInstance(name, false), which creates the directory, writes a blank ManifestInstance JSON file, and calls Manager.Index.RegisterInstance.Action bytes: (byte)CodeServices.Create = TerbinCRUD.Create, (byte)CodeServicesSection.Instances = 30

Request Payload

name
char[]
required
The name of the new instance. Written as a length-prefixed UTF-16 character array via WriteArray<char>. Colons (:) in the name are replaced with underscores internally.
path
char[]
Optional. A custom filesystem path for the instance. Parsed only if the remaining buffer length exceeds ThreeQuartersInt.Size bytes after reading name. Currently unused by Manager.Instances.NewInstance (marked TODO in source) — the instance is always created under rute_instances.

Response

On success the response body is empty (InfoResponse.CreateSucces with no payload bytes).

Error Conditions

InternalErrors valueCodeMeaning
InstanceCreate306Manager.Instances.NewInstance returned false — the directory already exists, another instance has the same name, or a filesystem error occurred.

Example

// Build the payload
Serialineitor s = new();
s.AddArray<char>("MyInstance".ToCharArray());

byte[] payload = s.Serialize();

// Send via IPC
var response = await client.Communicate(
    (byte)CodeServices.Create,
    (byte)CodeServicesSection.Instances,
    payload
);

if (response.Status == CodeStatus.Succes)
    Console.WriteLine("Instance created.");
Deletes an instance by name. The service calls Manager.Instances.Delete, which unregisters the instance from the index and then calls Manager.Node.DinamiteDirectory to recursively delete the entire instance folder from disk.Action bytes: (byte)CodeServices.Deleted, (byte)CodeServicesSection.Instances = 30

Request Payload

name
char[]
required
The exact name of the instance to delete, encoded as a length-prefixed UTF-16 char array.

Response

On success the response body is empty.

Error Conditions

InternalErrors valueCodeMeaning
InstanceNotExist302No instance with the given name is registered in the index (Manager.Instances.Status.ErrorNotExist).
InstanceIsNotInstance303The directory exists but is missing the instance manifest structure (Status.ErrorIsNotInstance).
InstanceUnregister305Manager.Index.UnregisterInstance returned false — the index could not be updated (Status.ErrorUnregistInstance).
NodeDinamite701Catch-all for any unrecognised Status returned by the manager.
Deletion is permanent and irreversible. The directory and all of its contents — game files, installed plugins, and manifests — are removed immediately by Directory.Delete(..., recursive: true).

Example

Serialineitor s = new();
s.AddArray<char>("MyInstance".ToCharArray());

var response = await client.Communicate(
    (byte)CodeServices.Deleted,
    (byte)CodeServicesSection.Instances,
    s.Serialize()
);

if (response.Status == CodeStatus.Succes)
    Console.WriteLine("Instance deleted.");
Returns a list of all registered instances from Manager.Index.GetAllInstances(). No request payload is needed.Action bytes: (byte)CodeServices.ReadAll = TerbinCRUD.ReadAll, (byte)CodeServicesSection.Instances = 30

Request Payload

None required. Any bytes sent are ignored.

Response Payload

If no instances are registered the response contains a single zero byte ([0]).Otherwise the response body is:
count
ThreeQuartersInt
Number of instances in the list (3-byte fixed-size integer).
instances[]
ReferenceInstanceDTO[]
Array of count consecutive ReferenceInstanceDTO structs, each containing Name, OutSide, and Path. Read with ReadStruct<ReferenceInstanceDTO> in a loop.

Example

var response = await client.Communicate(
    (byte)CodeServices.ReadAll,
    (byte)CodeServicesSection.Instances,
    Array.Empty<byte>()
);

if (response.Status == CodeStatus.Succes && response.Payload.Length > 1)
{
    ReadOnlySpan<byte> reader = response.Payload;
    int count = reader.Read<ThreeQuartersInt>();
    for (int i = 0; i < count; i++)
    {
        ReferenceInstanceDTO dto = reader.ReadStruct<ReferenceInstanceDTO>();
        Console.WriteLine(dto.Name);
    }
}
Fetches the full ManifestInstanceDTO for a single named instance by calling Manager.Instances.GetManifestByName.Action bytes: (byte)CodeServices.Read, (byte)CodeServicesSection.Instances = 30

Request Payload

name
char[]
required
The instance name, encoded as a length-prefixed UTF-16 char array.

Response Payload

On success the entire body is a serialized ManifestInstanceDTO struct:
Name
string
Instance name.
Version
string
Game version string stored in the manifest (empty until a game is cloned in).
PluginCount
ThreeQuartersInt
Number of plugins currently referenced in the manifest.

Error Conditions

InternalErrors valueCodeMeaning
InstanceNotExist302No instance was found for the provided name, or the manifest could not be deserialized.

Example

Serialineitor s = new();
s.AddArray<char>("MyInstance".ToCharArray());

var response = await client.Communicate(
    (byte)CodeServices.Read,
    (byte)CodeServicesSection.Instances,
    s.Serialize()
);

if (response.Status == CodeStatus.Succes)
{
    ManifestInstanceDTO dto = new();
    dto.ReadFrom(response.Payload);
    Console.WriteLine($"Name={dto.Name}, Version={dto.Version}, Plugins={dto.PluginCount}");
}

Build docs developers (and LLMs) love