Puerts.Lua.Complete 3.0.1

Prefix Reserved
dotnet add package Puerts.Lua.Complete --version 3.0.1
                    
NuGet\Install-Package Puerts.Lua.Complete -Version 3.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Puerts.Lua.Complete" Version="3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Puerts.Lua.Complete" Version="3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Puerts.Lua.Complete" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Puerts.Lua.Complete --version 3.0.1
                    
#r "nuget: Puerts.Lua.Complete, 3.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Puerts.Lua.Complete@3.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Puerts.Lua.Complete&version=3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Puerts.Lua.Complete&version=3.0.1
                    
Install as a Cake Tool

PuerTS — Lua for .NET

license Puerts.Lua.Complete

PuerTS is a scripting solution that brings Lua to your .NET applications. Built on Lua 5.4, it provides high-performance script execution with seamless C# interop — using the same unified ScriptEnv API as the JavaScript and Python backends.

Features

  • 🚀 High Performance — Powered by Lua 5.4, one of the fastest embeddable scripting languages.
  • 🔗 Seamless C# Interop — Call any .NET type directly from Lua, and invoke Lua functions from C#.
  • 🌍 Cross-Platform — Supports Windows, macOS, and Linux.
  • 🔄 Unified API — Same ScriptEnv architecture as JS and Python backends — easy to switch or mix languages.

Installation

Install via NuGet. The Complete package includes core + native assets for all desktop platforms:

dotnet add package Puerts.Lua.Complete

Or install components separately for finer control:

# Core library (required)
dotnet add package Puerts.Core

# Lua backend
dotnet add package Puerts.Lua

# Native assets per platform (choose what you need)
dotnet add package Puerts.Lua.NativeAssets.Win32
dotnet add package Puerts.Lua.NativeAssets.Linux
dotnet add package Puerts.Lua.NativeAssets.macOS

Supported Platforms

.net8.0+, .netstandard2.1

Windows (x64) Linux (x64) macOS (Universal)
Lua ✔️ ✔️ ✔️

Note: AOT compilation is not currently supported.

Quick Start

using Puerts;

var env = new ScriptEnv(new BackendLua());

// Execute Lua code
env.Eval(@"
    local CS = require('csharp')
    local Console = CS.System.Console
    Console.WriteLine('Hello from Lua!')
");

// Eval with return value (Lua requires explicit 'return')
int result = env.Eval<int>("return 1 + 2");
Console.WriteLine($"Lua result: {result}"); // output: 3

env.Dispose();

Calling C# from Lua

Access .NET types via require('csharp'):

local CS = require('csharp')
local Console = CS.System.Console
local DateTime = CS.System.DateTime
local List = CS.System.Collections.Generic.List(CS.System.String)

-- Create instances and call methods
local now = DateTime.Now
Console.WriteLine('Current time: ' .. now:ToString())

local list = List()
list:Add('hello')
list:Add('world')
Console.WriteLine('Count: ' .. tostring(list.Count))

Note: In Lua, instance methods use the colon syntax obj:Method(), while static methods use the dot syntax Class.Method().

Calling Lua from C#

using Puerts;
using System;

var env = new ScriptEnv(new BackendLua());

// Get a Lua function as a C# delegate
var add = env.Eval<Func<int, int, int>>("return function(a, b) return a + b end");
Console.WriteLine(add(10, 20)); // output: 30

// Get a Lua action
var greet = env.Eval<Action<string>>(@"
    return function(name)
        local CS = require('csharp')
        CS.System.Console.WriteLine('Hello, ' .. name .. '!')
    end
");
greet("PuerTS");

env.Dispose();

Key Differences from JS

Feature JavaScript Lua
Environment creation new ScriptEnv(new BackendV8()) new ScriptEnv(new BackendLua())
Console output console.log(...) print(...)
Accessing C# types CS.Namespace.Class require('csharp') to get namespace entry
Instance method calls obj.Method() obj:Method() (colon syntax)
Null representation null / undefined nil
Return from Eval Last expression auto-returned Explicit return required

Documentation

For full documentation, tutorials and API reference, visit: https://puerts.github.io/en

License

BSD 3-Clause

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.1 88 3/4/2026
3.0.0 340 12/15/2025
3.0.0-beta1 286 12/15/2025