mirror of https://github.com/bjornbytes/lovr.git
Pass:send supports tables;
This commit is contained in:
parent
f45706f875
commit
fcf64cb6e4
|
@ -568,14 +568,22 @@ static int l_lovrPassSend(lua_State* L) {
|
||||||
FieldType type;
|
FieldType type;
|
||||||
lovrPassSendValue(pass, name, length, &data, &type);
|
lovrPassSendValue(pass, name, length, &data, &type);
|
||||||
|
|
||||||
// readbufferfield doesn't handle booleans
|
int index = 3;
|
||||||
if (lua_type(L, 3) == LUA_TBOOLEAN) {
|
|
||||||
|
// readbufferfield doesn't handle booleans or tables; coerce/unpack
|
||||||
|
if (lua_isboolean(L, 3)) {
|
||||||
bool value = lua_toboolean(L, 3);
|
bool value = lua_toboolean(L, 3);
|
||||||
lua_settop(L, 2);
|
lua_settop(L, 2);
|
||||||
lua_pushinteger(L, value);
|
lua_pushinteger(L, value);
|
||||||
|
} else if (lua_istable(L, 3)) {
|
||||||
|
int length = luax_len(L, 3);
|
||||||
|
for (int i = 0; i < length && i < 16; i++) {
|
||||||
|
lua_rawgeti(L, 3, i + 1);
|
||||||
|
}
|
||||||
|
index = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
luax_readbufferfield(L, 3, type, data);
|
luax_readbufferfield(L, index, type, data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue