]> git.sesse.net Git - nageru/blobdiff - nageru/scene.cpp
Allow calling disable() on everything that has an IdentityEffect as alternative.
[nageru] / nageru / scene.cpp
index a3d3c6a20f172496f58b1509b82c59eccb0050e8..bebaa56d1af3b71b86f7868d9f4b345860267f3b 100644 (file)
@@ -537,11 +537,10 @@ int Block_disable(lua_State *L)
        assert(lua_gettop(L) == 1);
        Block *block = *(Block **)luaL_checkudata(L, 1, "Block");
 
-       if (block->alternatives.size() != 2 ||
-           block->alternatives[1]->effect_type != IDENTITY_EFFECT) {
-               luaL_error(L, "disable() called on something that wasn't added with add_optional_effect()");
-       }
        block->currently_chosen_alternative = find_index_of(block, IDENTITY_EFFECT);
+       if (block->currently_chosen_alternative == -1) {
+               luaL_error(L, "disable() called on something that didn't have an IdentityEffect fallback (try add_optional_effect())");
+       }
        assert(block->currently_chosen_alternative != -1);
        return 0;
 }