int MOAIFmodEventMgr::_playEvent2D ( lua_State* L ) {
    MOAILuaState state ( L );

    cc8* eventName = state.GetValue < cc8* > ( 1, "" );
    if ( eventName[0] != '\0' ) {
        
        const FMODDesigner::Event* pEvent = MOAIFmodEventMgr::Get().GetEvent( eventName );
        if ( !pEvent )
        {
            FMODDesigner::Event actualEvent = FMODDesigner::Event( STLString( eventName ) );
            MOAIFmodEventMgr::Get().AddEvent( eventName, actualEvent );
            pEvent = MOAIFmodEventMgr::Get().GetEvent( eventName );
        }
        
        
        if ( pEvent->IsValid() ) {
            bool bLoop = state.GetValue( 2, false );
            
            // Try to play the sound
            FMODDesigner::EventHandle hEventHandle = FMODDesigner::tEventManager.PlayEvent2D( *pEvent, bLoop );

            // Create a MOAI Event Instance and push it out
            MOAIFmodEventInstance* pEventInstance = new MOAIFmodEventInstance();
            pEventInstance->SetEventInstance( hEventHandle );   

            pEventInstance->PushLuaUserdata ( state );

            return 1;
        }        
    }
     
    return 0;
}
int MOAIFmodEventMgr::_unloadPendingUnloads ( lua_State* L ) {
    MOAILuaState state ( L );

    bool bBlockOnUnload = state.GetValue ( 1, false );
    FMODDesigner::tEventManager.UnloadPendingUnloads( bBlockOnUnload );
     
    return 0;
}
int MOAIFmodEventMgr::_loadGroup ( lua_State* L ) {
    MOAILuaState state ( L );

    cc8* groupName = state.GetValue < cc8* > ( 1, "" );
    if ( groupName[0] != '\0' )
    {
        bool bPersistent = state.GetValue ( 2, false );
        bool bBlockOnLoad = state.GetValue ( 3, false );

        bool bLoaded = FMODDesigner::tEventManager.LoadGroup ( STLString( groupName ), bPersistent, bBlockOnLoad );
         
        lua_pushboolean ( L, bLoaded );

        return 1;
    }

    return 0;
}
int MOAIFmodEventMgr::_unloadGroup ( lua_State* L ) {
    MOAILuaState state ( L );

    cc8* groupName = state.GetValue < cc8* > ( 1, "" );
    if ( groupName[0] != '\0' )
    {
        bool bUnloadImmediately = state.GetValue ( 2, false );    

        bool bUnloaded = FMODDesigner::tEventManager.UnloadGroup ( STLString( groupName ), bUnloadImmediately );

        lua_pushboolean ( L, bUnloaded );

        return 1;

    }

    return 0;
}