lovr.filesystem.getDirectoryItems works if table.sort is unavailable;

It just doesn't sort the output.
This commit is contained in:
bjorn 2022-02-21 14:04:58 -08:00
parent 88f367c0e5
commit a6a86fd908
1 changed files with 9 additions and 3 deletions

View File

@ -129,9 +129,15 @@ static int l_lovrFilesystemGetDirectoryItems(lua_State* L) {
}
lua_getglobal(L, "table");
lua_getfield(L, -1, "sort");
lua_pushvalue(L, 2);
lua_call(L, 1, 0);
if (lua_type(L, -1) == LUA_TTABLE) {
lua_getfield(L, -1, "sort");
if (lua_type(L, -1) == LUA_TFUNCTION) {
lua_pushvalue(L, 2);
lua_call(L, 1, 0);
} else {
lua_pop(L, 1);
}
}
lua_pop(L, 1);
return 1;
}