Esempio n. 1
0
int playstate::Component_FireEvent(lua_State* L)
{
    if(lua_gettop(L) < 3) {
        luaM_printerror(L, "Expected: self<Component>:FireEvent(typeID, messageID)");
        lua_pushnil(L);
        return 1;
    }

    uint32 messageID = lua_tointeger(L, -1);
    lua_pop(L, 1);
    uint32 typeID = lua_tointeger(L, -1);
    lua_pop(L, 1);
    Component* component = luaM_popobject<Component>(L);
    if(component != NULL) {
        SceneNode* node = component->GetNode();
        if(node != NULL)
            node->FireEvent(typeID, messageID);
        else
            luaM_printerror(L, "Cannot fire an event on a non-attached component");
    } else {
        luaM_printerror(L, "Expected: self<Component>:FireEvent(typeID, messageID)");
    }

    return 0;
}