X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fscene.cpp;h=a3d3c6a20f172496f58b1509b82c59eccb0050e8;hb=ca090e45b28fed464008086fbe3db19437c115dd;hp=d7da7db997ba1fbc3d4b74a7549ed36feaca1335;hpb=337e2d06624b4b46eb2e7e5365e2ece219f9f100;p=nageru diff --git a/nageru/scene.cpp b/nageru/scene.cpp index d7da7db..a3d3c6a 100644 --- a/nageru/scene.cpp +++ b/nageru/scene.cpp @@ -327,6 +327,8 @@ Scene::get_chain(Theme *theme, lua_State *L, unsigned num, const InputState &inp #endif } else if (block->signal_type_to_connect == Block::CONNECT_VIDEO) { signals_to_connect.emplace(input, block->video_to_connect->get_card_index()); + } else if (block->signal_type_to_connect == Block::CONNECT_NONE) { + luaL_error(L, "An input in a chain was not connected to anything (forgot to call display())"); } else { assert(false); } @@ -383,9 +385,6 @@ Scene::get_chain(Theme *theme, lua_State *L, unsigned num, const InputState &inp auto setup_chain = [L, theme, signals_to_connect, images_to_select, int_to_set, float_to_set, vec3_to_set, vec4_to_set, input_state]{ lock_guard lock(theme->m); - assert(theme->input_state == nullptr); - theme->input_state = &input_state; - // Set up state, including connecting signals. for (const auto &input_and_signal : signals_to_connect) { LiveInputWrapper *input = input_and_signal.first; @@ -428,8 +427,6 @@ Scene::get_chain(Theme *theme, lua_State *L, unsigned num, const InputState &inp value[0], value[1], value[2], value[3]); } } - - theme->input_state = nullptr; }; return make_pair(effect_chain, move(setup_chain)); } @@ -498,7 +495,22 @@ int Block_choose_alternative(lua_State* L) { assert(lua_gettop(L) == 2); Block *block = *(Block **)luaL_checkudata(L, 1, "Block"); - int alternative_idx = luaL_checknumber(L, 2); + int alternative_idx = -1; + if (lua_isnumber(L, 2)) { + alternative_idx = luaL_checknumber(L, 2); + } else if (lua_istable(L, 2)) { + // See if it's an Effect metatable (e.g. foo:choose_alternative(ResampleEffect)) + lua_getfield(L, 2, "__effect_type_id"); + if (lua_isnumber(L, -1)) { + EffectType effect_type = EffectType(luaL_checknumber(L, -1)); + alternative_idx = find_index_of(block, effect_type); + } + lua_pop(L, 1); + } + + if (alternative_idx == -1) { + luaL_error(L, "choose_alternative() called with something that was not an index or an effect type (e.g. ResampleEffect) that was part of the alternatives"); + } assert(alternative_idx >= 0); assert(size_t(alternative_idx) < block->alternatives.size());