feat: bytearray support in gfx.posteffects.set_array

This commit is contained in:
MihailRis 2026-04-26 17:38:48 +03:00
parent 8d9d1f9039
commit 4403df78d9
3 changed files with 9 additions and 6 deletions

View file

@ -41,8 +41,8 @@ gfx.posteffects.set_array(
slot: int,
-- parameter (array) name
name: str
-- data string (use Bytearray_as_string function)
data: str
-- data
data: Bytearray
)
-- Example of filling an array `#param vec3 u_arrayName[64]`:

View file

@ -41,8 +41,8 @@ gfx.posteffects.set_array(
slot: int,
-- имя параметра (массива)
name: string
-- строка данных (используйте функцию Bytearray_as_string)
data: string
-- данные
data: Bytearray
)
-- Пример заполнения массива `#param vec3 u_имяМассива[64]`:
@ -54,4 +54,4 @@ for i = 0, 63 do
Bytearray.append(buffer, byteutil.pack("fff", x, y, z))
end
gfx.posteffects.set_array(slot, "u_имяМассива", Bytearray_as_string(buffer))
```
```

View file

@ -770,7 +770,10 @@ namespace lua {
}
inline std::string_view bytearray_as_string(lua::State* L, int idx) {
lua::pushvalue(L, idx);
if (lua::type(L, idx) == LUA_TSTRING) {
return lua::tolstring(L, idx);
}
lua::pushvalue(L, idx);
lua::requireglobal(L, "Bytearray_as_string");
lua::pushvalue(L, -2);
lua::call(L, 1, 1);