Fix negative index for luax_readobjarr

This commit is contained in:
xiejiangzhi 2024-02-06 09:21:24 +08:00
parent 9e3336ad60
commit 1a321d004b
1 changed files with 2 additions and 1 deletions

View File

@ -579,7 +579,8 @@ int luax_readmesh(lua_State* L, int index, float** vertices, uint32_t* vertexCou
}
void luax_readobjarr(lua_State* L, int index, int n, float* out, const char* name) {
lovrCheck(lua_objlen(L, index) >= n, "length of %s table must >= %i", name, n);
lovrCheck(luax_len(L, index) >= n, "length of %s table must >= %i", name, n);
if (index < 0) index = lua_gettop(L) + index + 1;
for (int i = 0; i < n; i++) {
lua_rawgeti(L, index, i + 1);
out[i] = lua_tonumber(L, -1);