A TypeScript framework for programmatically creating RimWorld mods.
- Write mods easily with TypeScript / JavaScript
- Compile-time type checking saves development time
- Component-based design improves readability
- 📚 Expanded support for more Defs
- ⚡ Dynamic libraries based on JavaScript
- 🩹 Built-in patch support
Here’s a minimal working example of defining a custom weapon mod:
To get started, first install the rimworld-mod-maker package:
bun add rimworld-mod-makerThen, create an index.ts file with the following content:
import {
// This is entry point of the library
defineMod,
// Components
GraphicComponent, ItemComponent, MeleeWeaponComponent, RangedWeaponComponent, MeleeAttackComponent, RangedAttackComponent, GenericWeaponComponent,
// Some fixed types
GraphicType, VerbClass,
// Vanilla defs for reference
VanillaDamageDef, VanillaThingDef, VanillaToolCapacityDef
} from "rimworld-mod-maker";
// Define your mod
defineMod({
id: "demo-mod",
name: "Demo Mod",
author: "Xiaoeyun",
description: "A demo mod created using rimworld-mod-maker.",
version: "1.0.0",
supportedVersions: ["1.6"],
iconPath: "./assets/icon.png",
previewPath: "./assets/preview.png",
pretty: true,
clean: true,
output: "../../DemoMod",
}, ctx => {
// You can define contents here
ctx.defineWeapon({
name: "MyFourthWeapon",
label: "Blue Archiver Role",
description: "A simple ranged weapon created for demonstration purposes.",
}, [
ItemComponent({ mass: 3.0 }),
GraphicComponent(ctx.bundleTextures("./assets/ranagedWeapon.png"), GraphicType.Single),
GenericWeaponComponent(),
RangedWeaponComponent(),
RangedAttackComponent({
verbClass: VerbClass.Verb_Shoot,
defaultProjectile: VanillaThingDef.Bullet_AutocannonTurret,
hasStandardCommand: true,
warmupTime: 10,
range: 50,
burstShotCount: 150,
rpm: 1800,
muzzleFlashScale: 25,
}),
MeleeAttackComponent([
{
label: "Stab",
capacities: [VanillaToolCapacityDef.Stab],
power: 3,
cooldown: 2.5,
}
])
])
});bun install- To build the project:
bun run buildOur toolset is designed to save you time and reduce repetitive work:
dumper.py
Extracts XML definitions directly from the RimWorld game data directory and generates TypeScript type files (src/defs/vanilla.ts).python tools/dumper.py
- defs/ – various RimWorld definition types
- components/ – modular definition components
- utils.ts – Utility functions and type definitions
- xml.ts – Utilities for XML generation and manipulation
- io.ts – File operation helpers