示例#1
0
unsigned levent_id_for_name(const char *name)
{
  unsigned i = levent_index_for_name(name);
  if (i!=LEVENT_INVALID_INDEX)
    return levent_table[i].id;
  else
    return 0; // or -1 ? both appear at the end of the event list
}
示例#2
0
文件: luascript.c 项目: emlyn/chdk
/*
  return the index of an event, given it's name or event id
*/
static unsigned levent_index_from_id_lua_arg( lua_State* L, int index )
{
    if (lua_type(L, index) == LUA_TSTRING) {
        return levent_index_for_name(lua_tostring(L, index));
    }
    else if (lua_type(L,index) == LUA_TNUMBER) {
        return levent_index_for_id(lua_tonumber(L,index));
    }
    else {
        return luaL_error( L, "expected string or number" );
    }
}