zlua-delegate
/zlua-delegate
Przekazuje funkcje Lua i delegaty C# w obu kierunkach, obsługując parametry Action, Func oraz zdarzenia.
- Autor
- killop ↗
- Repozytorium
- unity-mcp ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 02.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 02.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Przekazuje funkcje Lua i delegaty C# w obu kierunkach, obsługując parametry Action, Func oraz zdarzenia.
Oryginalny opis (EN)
Marshals Lua functions and C# delegates: implicit Action and Func parameters, calling a callback from Lua, zlua.to_delegate, and add_/remove_ events. Use when a C# API takes or returns a delegate, Action, Func, or event handler.
Jak działa
- Lua function as a parameter
- Callbacks returned to Lua
Podgląd SKILL.md
---
name: zlua-delegate
description: >-
Marshals Lua functions and C# delegates: implicit Action and Func parameters,
calling a callback from Lua, zlua.to_delegate, and add_/remove_ events.
Use when a C# API takes or returns a delegate, Action, Func, or event handler.
---
# Delegates
Three paths. Do not collapse them into one.
| Path | How |
|------|-----|
| Lua function passed into a C# parameter | Pass `function(...) end`. ZLua builds a closed delegate from the parameter type |
| C# callback handed to Lua | Call it: `handler(...)`. It may be a Lua function or delegate userdata |
| C# calls a named Lua export | `LuaAppDomain.GetFunction<T>(module, method)`. See `zlua-csharp-call-lua` |
## Lua function as a parameter
```csharp
public void RegisterCallback(System.Action<int> onValue)
{
onValue?.Invoke(42);
}
```
```lua
host:RegisterCallback(function(v)
print("callback:", v)
end)
logic.Combine = function(a, b) return a + b end
```
| Lua argument | Result |
|--------------|--------|
| `function` | New closed delegate of the parameter type |
| `nil` | `null` |
| Existing delegate userdata | Passed through |
| Anything else | Type error |
Do not call `zlua.to_delegate` for this case. Use `zlua.to_delegate(fn, closedDelegateType)` only when Lua already has a function and the delegate type is not fixed by a C# parameter. The type argument must be a closed type such as `Action<int>`, not an open generic.
## Callbacks returned to Lua
```lua
local handler = host:GetHandler()
handler(42)
```
| Origin | `type(handler)` | Call |
|--------|-----------------|------|
| C# delegate | userdata with `__call` | `handler(...)` |
| Lua function that round-tripped through C# | `function` | `handler(...)` |
Do not use `handler:Invoke(...)`. That fails on a raw Lua function. An open delegate (`target == null`) is not supported.
`params` on a delegate bridge or on `GetFunction` is not supported. See `zlua-params`.
Events use `add_` / `remove_` with the same function reference. See `zlua-lua-call-csharp`.
Wersje
W bazie nie ma innych skilli o nazwie zlua-delegate.
Migawka bazy z 13.11.2026 · wersja paczki 6d84c4b9e1dd (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 95zlua-in-ref-out
Przekazuje parametry ref, in i out z C# do Lua, zwracając wiele wyników z parametrów out. - 95zlua-csharp-call-lua
Wywołuje Lua z C# przez LuaAppDomain i GetFunction, wiążąc metody modułów Lua z delegatami i przeładowując skrypty. - 85Lua C Integration
Omawia Lua C API do rozszerzania Lua kodem natywnym: operacje na stosie, wywołania C z Lua i odwrotnie, moduły C, userdata, metatabele i optymalizacje wydajności. - 90lua-guide
Pomaga pisać ogólne skrypty Lua 5.4+: moduły, zakresy zmiennych, metatabele, korutyny i obsługę błędów w plikach .lua. - 90rayfin-functions
Pomaga pisać funkcje zdefiniowane przez użytkownika w Rayfin, wywoływać je z frontendu i obsługiwać polecenia CLI. - 100grandma3-lua-api
Pomaga pisać i debugować wtyczki oraz skrypty Lua dla grandMA3 z użyciem Object API, dialogów UI i struktury wtyczek XML.