Project RimWorld Mod Maker

Expand description

RimWorld Mod Maker

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
  1. ๐Ÿ“š Expanded support for more Defs
  2. โšก Dynamic libraries based on JavaScript
  3. ๐Ÿฉน 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-maker

Then, 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,
}
])
])
});

Contribute to the project

  1. requirements:

    • Bun v1.1.30 or higher
    • Python 3.8 or higher (for tools)
  2. To install dependencies:

bun install
  1. To build the project:
bun run build

Our 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

Modulesยง

common
components
components/common
components/common/art
components/common/graphic
components/common/quality
components/hediff
components/item
components/item/ability
components/item/attack
components/item/recipe
components/item/weapon
defs
defs/damage
defs/research
defs/stat
defs/terrainAffordance
defs/thing
defs/thing/building
defs/thing/category
defs/thing/weapon
defs/vanilla
index
io
utils
xml