-
Notifications
You must be signed in to change notification settings - Fork 6
Creating Custom Commands
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
- 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)
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.
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.
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>| 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) |
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.";
}
}
}-
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.
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);- Set
<isEventCommand>true</isEventCommand>in the def. - The command will appear in the Events Editor / store.
- You can still read CustomData for costs, limits, etc.
- The purchase flow is handled by 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.
- Load your mod after RICS in the mod list.
- Start a game.
- Open the Command Editor (from the main RICS tab or menu).
- Your command should appear.
- Test it in chat (or use the debug tools).
- Use the Command Editor to tweak cooldown/permission/CustomData.
- Always use translations for user-facing strings.
- Respect the permission system (base
CanExecuteusually 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.
- Read Custom Command Settings for rich configuration UIs.
- Look at the core
Commands.xmland 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.