Advanced Command List

Results 1 to 9 of 9
  1. #1
    Apprentice N00b Winger is offline
    MemberRank
    Dec 2011 Join Date
    24Posts

    Advanced Command List

    Hello, today I release my advanced command list, which is great to manage commands from a configuration file. I didn't made the configuration loader + adder, but I made the rest.

    First, add this:

    Code:
    static Dictionary<string, string> Commands = new Dictionary<string, string>();
    Second, add some values. Insert into the first string the name of the command the user must type. Insert into the second string the name of the method/void to invoke.

    Third, make a new void (with parameter 'string Input') and add:
    Code:
                if (Commands.ContainsKey(Input))
                {
                    Type mType = typeof(Programma);
                    string Method = Commands[Input];
                    mType.GetMethod(Method).Invoke(null, null);
                }
                else
                {
                    Console.WriteLine("Sorry, the command {0} isn't found in the dictionary.", Input);
                }
    Fourth, in your main bootup add this: (Program.cs Main void)
    Code:
                while (true)
                {
                    NAME OF YOUR METHOD(Console.ReadLine());
                }
    It works :)
    I'll make the configuration adder in a few minutes and will release it.


  2. #2
    Banned Divide is offline
    BannedRank
    Aug 2011 Join Date
    British CoderLocation
    1,013Posts

    Re: Advanced Command List

    Now look if someone says ":)" they get an error saying "Sorry, the command ) isn't found in the dictionary."

  3. #3
    Apprentice N00b Winger is offline
    MemberRank
    Dec 2011 Join Date
    24Posts

    Re: Advanced Command List

    Quote Originally Posted by Divide View Post
    Now look if someone says ":)" they get an error saying "Sorry, the command ) isn't found in the dictionary."
    Yes absolute

  4. #4
    Alpha Member Danny is offline
    MemberRank
    Oct 2011 Join Date
    My PCLocation
    2,158Posts

    Re: Advanced Command List

    This is pretty nice, good release.

  5. #5
    Gamma Spamma Liam is online now
    MemberRank
    Dec 2011 Join Date
    Down UnderLocation
    2,945Posts

    Re: Advanced Command List

    This is okay, not 100% good, but it's okay

  6. #6
    Apprentice N00b Winger is offline
    MemberRank
    Dec 2011 Join Date
    24Posts

    Re: Advanced Command List

    Quote Originally Posted by MyKi View Post
    This is okay, not 100% good, but it's okay
    I have an command loader from file, but you still need to make your own voids.

  7. #7
    swagggggg Livar is offline
    MemberRank
    Oct 2008 Join Date
    United KingdomLocation
    2,272Posts

    Re: Advanced Command List

    I don't get it to be honest...

  8. #8
    Apprentice N00b Winger is offline
    MemberRank
    Dec 2011 Join Date
    24Posts

    Re: Advanced Command List

    Quote Originally Posted by PowahAlert View Post
    I don't get it to be honest...
    It rarely search for the inputted command, if it's in the dictionary, it'll search for the method (void, the value) and will invoke it.

  9. #9
    Account Upgraded | Title Enabled! Pookie is offline
    MemberRank
    Mar 2011 Join Date
    1,038Posts

    Re: Advanced Command List

    This is perfect. Thanks.



Advertisement