RSDK Script Development Skill
Overview
This skill provides comprehensive guidance for developing RSDK (Retro Engine Software Development Kit) scripts and mods. It covers RSDKv3, RSDKv4, and RSDKv5 (used in Sonic Mania), supporting the full mod development workflow from object scripting to scene design and complete mod packaging.
Core Capabilities
1. RSDK Version Detection and Setup
To determine the target RSDK version, check:
- User explicitly specifies version (RSDKv3/v4/v5)
- Project context indicates target game (Sonic Mania = RSDKv5, Sonic 1/2 Remastered = RSDKv4/v3)
- Default to RSDKv5 if unspecified (most common)
RSDK version differences:
- RSDKv3: Used in Sonic 1 Remastered, object scripts in C-like language
- RSDKv4: Used in Sonic 2 Remastered, enhanced object system
- RSDKv5: Used in Sonic Mania, most feature-rich, supports complex mods
2. Game Object (Object) Script Creation
To create an RSDK object script, follow this workflow:
- Define object properties: Determine object type, subtype, and attributes
- Write object script: Create
.txtscript file with proper RSDK syntax - Implement lifecycle functions:
Create,Update,Draw,StageLoad - Add collision and interaction logic: Touch responses, player interaction
- Test and validate: Check syntax and game behavior
Object script template structure:
// Object: [ObjectName]
// Type: [TypeID]
Create:
// Initialization code
return
Update:
// Per-frame update logic
return
Draw:
// Rendering code
return
StageLoad:
// Called when stage loads
return
3. Scene and Level Design
To design RSDK scenes and levels:
- Scene data structure: Understand scene format for target RSDK version
- Entity placement: Place objects, set positions and properties
- Trigger setup: Configure triggers, checkpoints, boundaries
- Layer management: Background/foreground layers, scrolling
- Collision and boundaries: Set up collision paths and stage boundaries
4. Code Templates and Snippets
The skill provides reusable code templates stored in assets/templates/:
- Basic Object Template: Minimal object with Create/Update/Draw
- Moving Platform Template: Platform with movement patterns
- Enemy Template: Basic enemy with AI behavior
- Collectible Template: Ring/monitor/item collection logic
- Player Interaction Template: Objects that respond to player contact
- Animation Template: Sprite animation control
- Sound Effect Template: SFX playback integration
5. Complete Mod Development
To develop a complete RSDK mod:
- Project structure setup: Create proper mod directory structure
- Object scripting: Develop all custom objects needed
- Scene modification: Edit or create scene data
- Asset integration: Sprites, sounds, backgrounds
- Mod metadata: Create
mod.inior equivalent config - Testing and debugging: Validate mod functionality
- Packaging: Prepare mod for distribution
RSDK Scripting Reference
Basic Syntax (RSDKv5)
RSDK scripting uses a C-like language with these key elements:
Variables and Types:
- int: Integer values
- float: Floating point values
- object: Object references
- entity: Entity references
Built-in Functions:
- GetPlayer(): Get player object
- CheckCollisionBox(): Collision detection
- DrawSprite(): Render sprites
- PlaySfx(): Play sound effects
- SetAnimation(): Set sprite animation state
Object Properties:
- position.x, position.y: Object position
- velocity.x, velocity.y: Movement velocity
- direction: Facing direction (0=left, 1=right)
- visible: Render toggle
- active: Update toggle
Version-Specific Differences
RSDKv5 enhancements:
- Enhanced animation system with animator object
- Improved collision with Collide() function
- Background scrolling with ScrollInfo structure
- Mod loader support with ModAPI integration
Workflow Guidance
Creating a New Object Script
- Determine object purpose and behavior
- Read
references/rsdkv5_api.mdfor relevant functions - Use template from
assets/templates/basic_object.txt - Implement required lifecycle functions
- Add object to mod's object list
- Test in-game using mod loader
Modifying Existing Objects
- Locate original object script in game data
- Create override in mod directory
- Modify desired behavior while preserving core functionality
- Test to ensure compatibility
Scene Editing Workflow
- Extract scene data using RSDK data extraction tools
- Parse scene format (version-specific)
- Modify entity placements or create new scene
- Repack scene data
- Test level in-game
Resources
references/
references/rsdkv5_api.md: Complete RSDKv5 API referencereferences/rsdkv3_api.md: RSDKv3 API reference (if needed)references/rsdkv4_api.md: RSDKv4 API reference (if needed)references/scene_formats.md: Scene data format documentationreferences/mod_structure.md: Mod directory structure guide
assets/templates/
assets/templates/basic_object.txt: Basic object templateassets/templates/moving_platform.txt: Moving platform templateassets/templates/enemy_basic.txt: Basic enemy AI templateassets/templates/collectible.txt: Collectible item templateassets/templates/player_interact.txt: Player interaction templateassets/templates/mod_ini.txt: mod.ini configuration template
scripts/
scripts/validate_syntax.py: Validate RSDK script syntaxscripts/generate_object.py: Generate object script from parametersscripts/package_mod.py: Package mod for distribution
Important Notes
- RSDK scripts are plain text files, typically with
.txtextension - Object type IDs must be unique within a mod
- Test mods using the RSDK mod loader for the target game
- Backup original game data before modding
- Respect copyright - do not distribute extracted game assets
Trigger words recap: RSDK, Retro Engine, Sonic Mania, 游戏模组, 对象脚本, Object script, RSDKv5, mod development, scene design, 关卡设计