diff --git a/doc/en/scripting/builtins/libgfx-posteffects.md b/doc/en/scripting/builtins/libgfx-posteffects.md index c624d557c..5e36683c4 100644 --- a/doc/en/scripting/builtins/libgfx-posteffects.md +++ b/doc/en/scripting/builtins/libgfx-posteffects.md @@ -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]`: diff --git a/doc/ru/scripting/builtins/libgfx-posteffects.md b/doc/ru/scripting/builtins/libgfx-posteffects.md index 01c13d888..64fb6c064 100644 --- a/doc/ru/scripting/builtins/libgfx-posteffects.md +++ b/doc/ru/scripting/builtins/libgfx-posteffects.md @@ -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)) -``` \ No newline at end of file +``` diff --git a/src/logic/scripting/lua/libs/libposteffects.cpp b/src/logic/scripting/lua/libs/libposteffects.cpp index 6eedaa6c8..3d714203b 100644 --- a/src/logic/scripting/lua/libs/libposteffects.cpp +++ b/src/logic/scripting/lua/libs/libposteffects.cpp @@ -65,7 +65,7 @@ static int l_set_params(lua::State* L) { static int l_set_array(lua::State* L) { size_t index = static_cast(lua::tointeger(L, 1)); auto key = lua::require_string(L, 2); - auto data = lua::require_lstring(L, 3); + auto data = lua::bytearray_as_string(L, 3); auto effect = post_processing->getEffect(index); if (effect == nullptr) { return 0; diff --git a/src/logic/scripting/lua/lua_util.hpp b/src/logic/scripting/lua/lua_util.hpp index 9ae1e48f6..a7881bef7 100644 --- a/src/logic/scripting/lua/lua_util.hpp +++ b/src/logic/scripting/lua/lua_util.hpp @@ -829,6 +829,9 @@ namespace lua { } inline std::string_view bytearray_as_string(lua::State* L, int idx) { + if (type(L, idx) == LUA_TSTRING) { + return tolstring(L, idx); + } pushvalue(L, idx); requireglobal(L, "Bytearray_as_string"); pushvalue(L, -2);