Przejdź do treści
Biblioteka skilli
Programowanie · Budowanie i kod

zlua-in-ref-out

/zlua-in-ref-out

Przekazuje parametry ref, in i out z C# do Lua, zwracając wiele wyników z parametrów out.

Repozytorium
unity-mcp ↗
Licencja
MIT
Ostatnia zmiana repozytorium
02.11.2026

Ocena i bezpieczeństwo

95/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść30 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 02.11.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Przekazuje parametry ref, in i out z C# do Lua, zwracając wiele wyników z parametrów out.

Oryginalny opis (EN)

Marshals C# ref, in, and out parameters with ZLua. Use when a method has ref, in, or out arguments, when Lua should receive multiple results from out parameters, or when a byref write does not show up in the Lua value.

Jak działa

  1. out
  2. ref and in write-back
  3. Opaque from C to Lua
Sekcje z nagłówków SKILL.md, w oryginale · 53 linii, 348 słów
Podgląd SKILL.md
---
name: zlua-in-ref-out
description: >-
  Marshals C# ref, in, and out parameters with ZLua. Use when a method has
  ref, in, or out arguments, when Lua should receive multiple results from out
  parameters, or when a byref write does not show up in the Lua value.
---

# ref, in, and out

C# keeps its own meanings (`in` is readonly). Lua does not treat the three keywords the same on a Lua-to-C# call.

| Direction | Behavior |
|-----------|----------|
| C# to Lua (`GetFunction`, delegate bridge) | `ref` / `in` / `out` push an OpaqueValue by default |
| Lua to C#, `ref` / `in` | Still consume a Lua argument. Write-back depends on that argument's shape |
| Lua to C#, `out` | Consumes no Lua argument. After the call, values are extra results: `return, out1, out2, ...` |

## out

```lua
-- void GetPosition(out float x, out float y, out float z)
local x, y, z = Demo.GetPosition()

-- bool TryGet(out float x, out float y)
local ok, x, y = Demo.TryGet()

-- bool TryParseScaled(string text, out int value)
local ok, value = Demo.TryParseScaled("21")
```

Do not pass a number as a placeholder for `out`. The full signature key still spells the byref type (`GetPosition(System.Single&,System.Single&,System.Single&)`), but the Lua arity does not count those parameters.

## ref and in write-back

| Lua argument | C# writes are visible in that Lua value |
|--------------|-----------------------------------------|
| OpaqueValue (`zlua.get_opaquevalue` / `set_opaquevalue`) | Yes |
| ByVal userdata whose type equals the element type | Yes, including struct fields |
| Bare number, Lua string, or most ByObj userdata | No. The value is copied into a temporary |

```lua
local x = 5
Demo.Increment(x)          -- ref int: x stays 5

local p = Point2D(1, 2)
Demo.Offset(p)             -- ref Point2D: p's fields update
```

Use `ref` when Lua must observe the write. Use `out` when the method only produces values.

## Opaque from C# to Lua

```lua
local v = zlua.get_opaquevalue(slot)
zlua.set_opaquevalue(slot, newValue)
```

An Opaque handle is valid only for the synchronous call chain. Do not store it across `pcall` or across frames. To keep a userdata, copy with `zlua.to_user_data`. Forcing another marshal shape is `[LuaMarshalAs]` / XML; see `zlua-marshal-as`. `ref` / `in` / `out` already default to Opaque on the C# to Lua path, so do not add `OpaqueValue` unless the slot is by value.

Wersje

W bazie nie ma innych skilli o nazwie zlua-in-ref-out.

Migawka bazy z 13.11.2026 · wersja paczki 8860fb1c7304 (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-delegate
    Przekazuje funkcje Lua i delegaty C# w obu kierunkach, obsługując parametry Action, Func oraz zdarzenia.
  • 95zlua-generic-method
    Zamyka typy generyczne C# w Lua przez make_generic_type, zlua.inflate i prefiksy GTAP, na przykład dla List<T>.
  • 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.
  • 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.
  • 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.
  • 100lua-embedding-scripting
    Osadza środowisko Lua w aplikacjach w C, Go i Rust, żeby obsługiwać skrypty pluginów i reguły konfiguracji.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.