| Crates.io | protoc-gen-luau |
| lib.rs | protoc-gen-luau |
| version | 1.0.1 |
| created_at | 2025-12-11 05:15:49.499379+00 |
| updated_at | 2025-12-12 06:06:09.15978+00 |
| description | A protobuf generator for Luau |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1979186 |
| size | 22,023,775 |
protoc-gen-luau generates strictly typed Luau files from Protobuf files.
To use, clone the repo and run cargo install. When you run protoc, add --luau_out=path/to/protos. For example, to export protos in protos/ to src/LuauProtos/...
protoc -Iprotos --luau_out=src/LuauProtos
Add --luau_opt=roblox_imports=true to indicate you are in a Roblox environment. This currently replaces requires from string requires to instance based requires. I'm not actually sure this is necessary anymore though.
Suppose we have the following message:
message Pair {
double x = 1;
double y = 2;
}
The exported script will have the following:
Pair representing the Pair classPair class with:
Pair.new(partialFields): Pair
partialFields in this case would be { x: number?, y: number? }. Anything not specified will be defaulted as per Protobuf's rules.Pair:encode(): buffer
Pair.decode(input: buffer): Pair
Pair:jsonEncode(): { [string]: any }
Pair.jsonDecode(input: { [string]: any }): Pair
Pair.descriptor: proto.Descriptor
{ name: string, fullName: string }.If we have the following:
enum Kind {
A = 0,
B = 1,
C = 2,
}
The exported script will export a type Kind that is a union string of all the options, as well as number for when it is unspecified. In this case: "A" | "B" | "C" | number
Any is supported, though these docs are not ready yet.