Newbie Spellweaver
- Joined
- Dec 24, 2011
- Messages
- 16
- Reaction score
- 1
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:
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:
Fourth, in your main bootup add this: (Program.cs Main void)
It works
I'll make the configuration adder in a few minutes and will release it.
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.