Skip to content

struct / class

OOP

Declare the type in a .clh. Implement Class::Method in the sibling .clp / .clpp.

struct LeaderstatsServer {
Janitor janitor;
void OnPlayer(Player player);
};

None.

A type (and, for field-only headers, a constructor function).

export type + function Class:Method / const function Name() for field-only

class is a synonym of struct. public: / private: / protected: are ignored.

Field-only structs in a header emit const function Name() with defaults (DataStore templates). Nested structs with defaults become nested tables.

Stems must match: LeaderstatsServer.clh beside LeaderstatsServer.server.clpp.

Instances are not RAII. Leaving a block does not Destroy — use Janitor.

struct LeaderstatsServer {
Janitor janitor;
};

Emits:

-- export type LeaderstatsServer = { janitor: Janitor, ... }

class-method · this · init · access-labels