Skip to content

Creating Custom Commands

ekudram edited this page Jul 4, 2026 · 2 revisions

Creating Custom Commands for RICS

This guide shows you how to create your own RimWorld mod that adds new chat commands to [CAP] Rimworld Interactive Chat Services (RICS).

With this system you can:

  • Add completely new commands (e.g. !mycommand)
  • Create buyable event commands (like custom raids or effects)
  • Expose per-command settings in the in-game Command Editor
  • Integrate tightly with RICS's permission, cooldown, economy, and viewer systems

Prerequisites

  • You know the basics of creating a RimWorld mod (folder structure, About.xml, Defs, Assemblies)
  • Basic C# knowledge (you will write a small class that inherits from ChatCommand)
  • RICS installed (you will depend on it)

1. Mod Folder Structure

A minimal custom command mod looks like this:

YourCustomCommands/
├── About/
│   └── About.xml
├── Defs/
│   └── Commands/
│       └── MyCustomCommands.xml
├── Source/
│   └── YourCustomCommands/
│       └── MyCommands.cs
└── Assemblies/          (optional - put your compiled DLL here)
    └── YourCustomCommands.dll

You can develop directly against the RICS source or reference its DLL.

2. About.xml – Declare Dependency on RICS

Your About/About.xml must declare RICS as a dependency and load after it:

<ModMetaData>
  <name>Your Custom Commands</name>
  <author>YourName</author>
  <packageId>YourName.YourCustomCommands</packageId>
  <supportedVersions>
    <li>1.6</li>
  </supportedVersions>
  <description>Adds awesome new commands to RICS.</description>

  <modDependencies>
    <li>
      <packageId>Captolamia.RICS</packageId>
      <!-- 
         Release version (Steam): packageId is Captolamia.RICS (folder is usually "[CAP] RICS")
         Dev/Beta version: packageId is Captolamia.RICS.Beta

         Always check the actual packageId inside the installed RICS mod's About/About.xml
      -->
    </li>
  </modDependencies>

  <loadAfter>
    <li>Captolamia.RICS</li>
  </loadAfter>
</ModMetaData>

Important: Your mod must load after RICS so that the CAP_ChatInteractive.ChatCommandDef type is available when your XML is parsed.

3. Define Your Command(s) in XML

Create Defs/Commands/MyCustomCommands.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Defs>

  <CAP_ChatInteractive.ChatCommandDef>
    <defName>MyAwesomeCommand</defName>
    <commandText>myawesome</commandText>
    <label>my awesome</label>
    <enabled>true</enabled>

    <!-- Full namespace + class name of your C# implementation -->
    <commandClass>YourName.YourCustomCommands.MyAwesomeCommand</commandClass>

    <commandDescription>Does something really cool for chat!</commandDescription>

    <permissionLevel>everyone</permissionLevel>
    <cooldownSeconds>30</cooldownSeconds>
    <useCommandCooldown>true</useCommandCooldown>

    <!-- Optional: Make this a buyable event command -->
    <!-- <isEventCommand>true</isEventCommand> -->

    <!-- See the Custom Command Settings page for rich per-command UI -->
    <!-- <CustomData> ... </CustomData> -->
  </CAP_ChatInteractive.ChatCommandDef>

</Defs>

Key Fields

Field Description
defName Unique internal name
commandText What viewers type (without !)
label Display name in editors
commandClass Full C# type name (must inherit ChatCommand)
commandDescription Shown in help / editors
permissionLevel everyone / subscriber / vip / moderator / broadcaster
cooldownSeconds Cooldown in seconds
useCommandCooldown Use the per-command cooldown system
isEventCommand Makes it purchasable via the store (events tab)
CustomData Per-command settings (see separate guide)

4. Implement the Command in C#

Create a class that inherits from ChatCommand:

using CAP_ChatInteractive;
using Verse;

namespace YourName.YourCustomCommands
{
    public class MyAwesomeCommand : ChatCommand
    {
        public override string Name => "myawesome";

        public override string Execute(ChatMessageWrapper messageWrapper, string[] args)
        {
            var viewer = Viewers.GetViewer(messageWrapper);
            if (viewer == null)
                return "Could not find your viewer data.";

            // Do something cool...
            return $"Thanks {viewer.DisplayName}! Your awesome command worked.";
        }
    }
}

Useful Base Class Members

  • Name (required)
  • Execute(...) (required)
  • GetCommandSettings() → access per-command settings + CustomData
  • CanExecute(...) (override for custom permission logic)
  • PermissionLevel, CooldownSeconds, Alias (usually come from settings / Def)

You can also override OnCustomDataButtonClicked if you use the Button type in CustomData.

5. Using Per-Command Settings (CustomData)

See the Custom Command Settings page for full details.

Quick example in XML:

<CustomData>
  <li>
    <type>CheckBox</type>
    <name>enableSpecialEffect</name>
    <label>Enable special effect</label>
    <defaultValue>true</defaultValue>
  </li>
  <li>
    <type>NumericTextBox</type>
    <name>specialMultiplier</name>
    <label>Multiplier</label>
    <defaultValue>1.0</defaultValue>
    <min>0.1</min>
    <max>10</max>
  </li>
</CustomData>

In code:

var settings = GetCommandSettings();
bool effectEnabled = settings.GetCustom<bool>("enableSpecialEffect", true);
float mult = settings.GetCustom<float>("specialMultiplier", 1.0f);

6. Making Buyable Event Commands

  1. Set <isEventCommand>true</isEventCommand> in the def.
  2. The command will appear in the Events Editor / store.
  3. You can still read CustomData for costs, limits, etc.
  4. The purchase flow is handled by RICS.

7. Compiling & Referencing RICS

In your .csproj:

<ItemGroup>
  <Reference Include="CAP Chat Interactive">
    <HintPath>..\..\[CAP] Chat Interactive\1.6\Assemblies\[CAP] Chat Interactive.dll</HintPath>
    <Private>False</Private>
  </Reference>
</ItemGroup>

Or develop using the full RICS source.

8. Testing Your Commands

  1. Load your mod after RICS in the mod list.
  2. Start a game.
  3. Open the Command Editor (from the main RICS tab or menu).
  4. Your command should appear.
  5. Test it in chat (or use the debug tools).
  6. Use the Command Editor to tweak cooldown/permission/CustomData.

Tips & Best Practices

  • Always use translations for user-facing strings.
  • Respect the permission system (base CanExecute usually does the right thing).
  • Use GetCommandSettings().GetCustom<T>() for anything configurable per-command.
  • For complex commands, look at how core commands are structured (see CommandHandlers/ folder in RICS).
  • You can add CustomData to existing RICS commands too (via patches) if you want to extend them.
  • Test with both regular viewers and moderators.

Next Steps

  • Read Custom Command Settings for rich configuration UIs.
  • Look at the core Commands.xml and command classes for real-world examples.
  • Share your commands on the RICS GitHub discussions or Steam page!

Happy modding! If you create cool commands, the community would love to see them.

Clone this wiki locally