diff --git a/Modules.md b/Modules.md new file mode 100644 index 0000000..6a0af06 --- /dev/null +++ b/Modules.md @@ -0,0 +1,34 @@ +# SrcMod/Modules +Modules in SrcMod are how commands are grouped. A module can have an id which must be prefixed before the command name and parameters when parsed. Modules are declared by applying the `ModuleAttribute` attribute in the namespace `SrcMod.Shell.Modules.ObjectModels` to a class. The classes can be static. + +Here is an example: +```csharp +// Used for the `ModuleAttribute`. +using SrcMod.Shell.Modules.ObjectModels; + +[Module("example1")] +public static class ExampleModule1 +{ + // Invoked by executing "example1 " +} +``` + +The `ModuleAttribute` attribute requires you to supply a `nameId`. This will be what prefixes the command name ID in a command string. Optionally, there is also a boolean `nameIsPrefix`, which by default is set to `true`. If the parameter is `false`, commands in that module will not require the module name ID to be prefixed. + +```csharp +// Used for the `ModuleAttribute`. +using SrcMod.Shell.Modules.ObjectModels; + +[Module("example2", false)] +public static class ExampleModule2 +{ + // The module ID is not a prefix. + // Invoked by executing " " +} +``` + +Inside the class will be the commands in that module. + +--- + +**Note: When using the `srcmod.dll` to add additional custom modules, the new modules will not be recognized due to a reflection bug. This will be fixed in the near future (see issue #2).**