mirror of
https://github.com/mpv-player/mpv
synced 2025-04-08 10:32:51 +00:00
lua: simplify further
As suggested by avih. Obviously this was unnecessarily convoluted.
This commit is contained in:
parent
d375cc304a
commit
8a58a69930
@ -504,17 +504,10 @@ static int script_wait_event(lua_State *L)
|
|||||||
|
|
||||||
mpv_event *event = mpv_wait_event(ctx->client, luaL_optnumber(L, 1, 1e20));
|
mpv_event *event = mpv_wait_event(ctx->client, luaL_optnumber(L, 1, 1e20));
|
||||||
|
|
||||||
lua_newtable(L); // event
|
|
||||||
|
|
||||||
struct mpv_node rn;
|
struct mpv_node rn;
|
||||||
mpv_event_to_node(&rn, event);
|
mpv_event_to_node(&rn, event);
|
||||||
|
|
||||||
assert(rn.format == MPV_FORMAT_NODE_MAP);
|
pushnode(L, &rn); // event
|
||||||
mpv_node_list *list = rn.u.list;
|
|
||||||
for (int n = 0; n < list->num; n++) {
|
|
||||||
pushnode(L, &list->values[n]);
|
|
||||||
lua_setfield(L, -2, list->keys[n]);
|
|
||||||
}
|
|
||||||
|
|
||||||
mpv_free_node_contents(&rn);
|
mpv_free_node_contents(&rn);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user