{"id":48561151,"url":"https://github.com/rosslight/darp-luau","last_synced_at":"2026-04-08T12:18:09.063Z","repository":{"id":344851494,"uuid":"1142394413","full_name":"rosslight/darp-luau","owner":"rosslight","description":"Darp.Luau is a .NET wrapper around Luau focused on native AOT compatibility, typed value access, and explicit ownership for Luau-backed references.","archived":false,"fork":false,"pushed_at":"2026-03-23T16:24:36.000Z","size":342,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-24T09:13:28.439Z","etag":null,"topics":["csharp","dotnet","lua","luau","nativeaot"],"latest_commit_sha":null,"homepage":"https://rosslight.github.io/darp-luau/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rosslight.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-26T10:58:42.000Z","updated_at":"2026-03-23T16:24:23.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rosslight/darp-luau","commit_stats":null,"previous_names":["rosslight/darp-luau"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rosslight/darp-luau","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosslight%2Fdarp-luau","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosslight%2Fdarp-luau/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosslight%2Fdarp-luau/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosslight%2Fdarp-luau/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rosslight","download_url":"https://codeload.github.com/rosslight/darp-luau/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosslight%2Fdarp-luau/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31554969,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","lua","luau","nativeaot"],"created_at":"2026-04-08T12:18:08.033Z","updated_at":"2026-04-08T12:18:09.047Z","avatar_url":"https://github.com/rosslight.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Darp.Luau\n\n[![Darp.Results](https://img.shields.io/nuget/v/Darp.Luau.svg)](https://www.nuget.org/packages/Darp.Luau)\n[![Downloads](https://img.shields.io/nuget/dt/Darp.Luau)](https://www.nuget.org/packages/Darp.Luau)\n![License](https://img.shields.io/github/license/rosslight/darp-luau)\n![.NET](https://img.shields.io/badge/version-.NET10-blue)\n\n`Darp.Luau` is a .NET wrapper around [Luau](https://luau.org/) focused on native AOT compatibility, typed value access, and explicit ownership for Luau-backed references.\n\n## Why another lua library\n\n- NativeAOT first\n- Typed reads and writes for tables, functions, userdata, strings, and buffers\n- Clear lifetime guarantees both stability and performance\n- Simple API through source-generated interceptors\n- Custom libraries and managed userdata\n- Support for `linux`,`windows`,`macos` on both `x64`,`arm64`\n\n## Quick start\n\n```csharp\nusing Darp.Luau;\n\nusing var lua = new LuauState();\n\nusing LuauFunction log = lua.CreateFunction((string message) =\u003e Console.WriteLine(message));\nlua.Globals.Set(\"log\", log);\n\nusing LuauTable config = lua.CreateTable();\nconfig.Set(\"name\", \"Ada\");\nconfig.Set(\"enabled\", true);\nlua.Globals.Set(\"config\", config);\n\nlua.Load(\n    \"\"\"\n    function add(a, b)\n      return a + b\n    end\n\n    log(config.name)\n    result = add(20, 22)\n    \"\"\"\n).Execute();\n\ndouble result = lua.Globals.GetNumber(\"result\");\n```\n\n## Call Lua functions from C#\n\n```csharp\nusing LuauFunction add = lua.Globals.GetLuauFunction(\"add\");\ndouble sum = add.Invoke\u003cdouble\u003e(1, 2);\n\nusing LuauFunction pair = lua.Globals.GetLuauFunction(\"pair\");\n(int total, int delta) = pair.Invoke\u003cint, int\u003e(20, 4);\n```\n\n`Invoke\u003cTR\u003e(...)` converts a single Luau return value to the managed type you ask for and ignores extras. Use `Invoke\u003cTR1, TR2\u003e(...)`, ... for typed multi-return calls, and `InvokeMulti(...)` for raw `LuauValue[]` access. The current argument buffer accepts up to 4 arguments per call.\n\n`Load(...).Execute(...)` follows the same return-shaping pattern for chunk execution: use `Load(...).Execute\u003cTR\u003e()` for the first typed return value, `Load(...).Execute\u003cTR1, TR2\u003e()`, ... for typed multi-return calls, and `Load(...).ExecuteMulti()` for raw `LuauValue[]` access.\n\n```csharp\n(int total, int delta) = lua.Load(\"return 20, 4\").Execute\u003cint, int\u003e();\n```\n\n## Expose managed callbacks\n\nUse `CreateFunction(...)` for supported fixed delegate signatures:\n\n```csharp\nusing LuauFunction sum = lua.CreateFunction((int a, int b) =\u003e a + b);\nlua.Globals.Set(\"sum\", sum);\n\nusing LuauFunction pair = lua.CreateFunction((int a, int b) =\u003e (a + b, a - b));\nlua.Globals.Set(\"pair\", pair);\n```\n\nUse `CreateFunctionBuilder(...)` when you need manual argument parsing, explicit user-facing errors, or a callback shape that the generator-backed path does not support:\n\n```csharp\nusing LuauFunction pair = lua.CreateFunctionBuilder(static args =\u003e\n{\n    if (!args.TryValidateArgumentCount(2, out string? error))\n        return LuauReturn.Error(error);\n    if (!args.TryReadNumber(1, out int a, out error) || !args.TryReadNumber(2, out int b, out error))\n        return LuauReturn.Error(error);\n    if (a \u003c= b)\n        return LuauReturn.Error(\"Expected a to be greater than b\");\n\n    return LuauReturn.Ok(a + b, a - b);\n});\n```\n\n`CreateFunction(...)` must be called directly at the call site so the generator can intercept it. It supports fixed delegate signatures, including supported top-level tuple returns. If you need a shape that is not supported there, use `CreateFunctionBuilder(...)`.\n\n## Work with tables\n\n```csharp\nusing LuauTable settings = lua.CreateTable();\nsettings.Set(\"volume\", 0.8);\nsettings.Set(\"muted\", false);\nsettings.Set(\"blob\", new byte[] { 1, 2, 3 });\n\nlua.Globals.Set(\"settings\", settings);\n\nusing LuauTable roundTripped = lua.Globals.GetLuauTable(\"settings\");\ndouble volume = roundTripped.GetNumber(\"volume\");\nbool muted = roundTripped.GetBoolean(\"muted\");\nbyte[] blob = roundTripped.GetBuffer(\"blob\");\n```\n\nUse `Get*` for required values, `TryGet*` for optional or external data, and `*OrNil` when `nil` is part of the contract.\n\n## Work with userdata\n\n```csharp\nvar player = new PlayerUserdata { Name = \"Ada\" };\n\nlua.Globals.Set(\"player\", IntoLuau.FromUserdata(player));\n\nPlayerUserdata samePlayer = lua.Globals.GetUserdata\u003cPlayerUserdata\u003e(\"player\");\n\nusing LuauUserdata playerRef = lua.Globals.GetLuauUserdata(\"player\");\n_ = playerRef.TryGetManaged(out PlayerUserdata? resolvedPlayer, out string? error);\n```\n\nManaged userdata types implement `ILuauUserData\u003cT\u003e` to expose script-facing fields, setters, and methods. See [Userdata](docs/features/userdata.md) for the full hook model.\n\n`CreateFunction(...)` also supports managed userdata parameters and returns for types that implement `ILuauUserData\u003cTSelf\u003e`.\n\n## Register custom libraries\n\n```csharp\nlua.OpenLibrary(\"game\", static (state, in LuauTable lib) =\u003e\n{\n    lib.Set(\"answer\", 42);\n\n    using LuauFunction add = state.CreateFunction((int a, int b) =\u003e a + b);\n    lib.Set(\"add\", add);\n});\n```\n\n`OpenLibrary(...)` registers a global table. It is a convenient way to expose host-provided APIs, but it is not a `require(...)`-style module loader by itself.\n\n## Ownership and lifetime\n\n- `LuauTable`, `LuauFunction`, `LuauString`, `LuauBuffer`, `LuauUserdata`, and reference-backed `LuauValue` are owned references and should be disposed.\n- `LuauTableView`, `LuauFunctionView`, `LuauStringView`, `LuauBufferView`, `LuauUserdataView`, and `LuauArgs` are borrowed callback-scoped values.\n- Reference-backed values belong to one `LuauState`; cross-state usage is invalid.\n\n## Current boundaries\n\n- `Load(...).Execute(...)` is the script execution API today. If you want file-based execution, read the file yourself and pass its contents in.\n- `CreateFunction(...)` is generator-backed and has no runtime fallback.\n- `LuauState` is not thread-safe.\n- A documented module system and higher-level async/thread orchestration are not part of the current surface yet.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosslight%2Fdarp-luau","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frosslight%2Fdarp-luau","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosslight%2Fdarp-luau/lists"}