EddiSpeechResponder.Personality.FromName C# (CSharp) Method

FromName() public static method

public static FromName ( string name ) : Personality
name string
return Personality
        public static Personality FromName(string name)
        {
            if (name == "EDDI")
            {
                return Default();
            }
            else
            {
                return FromFile(Constants.DATA_DIR + @"\personalities\" + name.ToLowerInvariant() + ".json");
            }
        }

Usage Example

コード例 #1
0
ファイル: SpeechResponder.cs プロジェクト: pekwalker/EDDI
        /// <summary>
        /// Change the personality for the speech responder
        /// </summary>
        /// <returns>true if the speech responder is now using the new personality, otherwise false</returns>
        public bool SetPersonality(string newPersonality)
        {
            SpeechResponderConfiguration configuration = SpeechResponderConfiguration.FromFile();

            if (newPersonality == configuration.Personality)
            {
                // Already set to this personality
                return(true);
            }

            // Ensure that this personality exists
            Personality personality = Personality.FromName(newPersonality);

            if (personality != null)
            {
                // Yes it does; use it
                configuration.Personality = newPersonality;
                configuration.ToFile();
                scriptResolver = new ScriptResolver(personality.Scripts);
                Logging.Debug("Changed personality to " + newPersonality);
                return(true);
            }
            else
            {
                // No it does not; ignore it
                return(false);
            }
        }
All Usage Examples Of EddiSpeechResponder.Personality::FromName