Exemplo n.º 1
0
bool am_execute_node_actions(lua_State *L, am_scene_node *node) {
    lua_rawgeti(L, LUA_REGISTRYINDEX, AM_ACTION_TABLE);
    int actions_tbl = am_absindex(L, -1);
    int from = num_actions + 1;
    add_actions(L, node, actions_tbl);
    int to = num_actions;
    lua_pushinteger(L, from);
    lua_pushinteger(L, to);
    return am_call_amulet(L, "_execute_actions", 3, 0);
}
Exemplo n.º 2
0
static int node_add_actions(lua_State *L) {
    am_scene_node *node = am_get_userdata(L, am_scene_node, 1);
    lua_rawgeti(L, LUA_REGISTRYINDEX, AM_ACTION_TABLE);
    int actions_tbl = am_absindex(L, -1);
    int from = num_actions + 1;
    add_actions(L, node, actions_tbl);
    int to = num_actions;
    lua_pushinteger(L, from);
    lua_pushinteger(L, to);
    return 3;
}
Exemplo n.º 3
0
int am_get_enum_raw(lua_State *L, int enum_id, int idx) {
    idx = am_absindex(L, idx);
    lua_rawgeti(L, LUA_REGISTRYINDEX, enum_id);
    if (!lua_istable(L, -1)) {
        return luaL_error(L, "INTERNAL ERROR: enum %d not initialized");
    }
    lua_pushvalue(L, idx);
    lua_rawget(L, -2);
    if (lua_isnil(L, -1)) {
        const char *name = lua_tostring(L, idx);
        if (name == NULL) {
            name = lua_typename(L, lua_type(L, idx));
        }
        return luaL_error(L, "invalid enum value '%s'", name);
    }
    int val = lua_tointeger(L, -1);
    lua_pop(L, 2);
    return val;
}