Mother DocsMother Docs
Buy me a Coffee
Steam Workshop
Discord
  • Mother OS (Ingame Script)
Buy me a Coffee
Steam Workshop
Discord
  • Mother OS (Ingame Script)
  • Mother OS (Ingame Script)
    • Getting Started

      • Upgrade Guide
      • Installation
      • Command Line Interface (CLI)
      • Configuration
      • Modules
    • Core Modules

      • Activity Monitor
      • Almanac
      • Block Catalogue
      • Local Storage
      • Intergrid Message Service
    • Extension Modules

      • Air Vent Module
      • Battery Module
      • Terminal Block Module
      • Cockpit Module
      • Connector Module
      • Display Module
      • Docking Module
      • Door Module
      • Flight Control Module
      • Flight Planning Module
      • Gas Tank Module
      • Gyroscope Module
      • Hinge Module
      • Landing Gear Module
      • Light Module
      • Map Module
      • Piston Module
      • Programmable Block Module
      • Rotor Module
      • Screen Module
      • Sensor Module
      • Sorter Module
      • Sound Block Module
      • Thruster Module
      • Timer Block Module
    • Command Cheatsheet
    • Compatibility
    • Examples
  • Mother Core (Script Framework)
    • Getting Started

      • Upgrade Guide
      • Installation
      • Architecture Overview
      • Managing Script Size & Complexity
    • Building A Module
    • Console (CLI)
    • Core Modules
      • Activity Monitor
      • Almanac
      • Block Catalogue
      • Clock
      • Command Bus
      • Configuration
      • Event Bus
      • Intergrid Message Service
      • Local Storage
      • Terminal
    • Utilities

      • Color Helper
      • Security
      • Serializer
  • Powered By Mother

Mother Core (Script Framework)

Static Badge

Mother Core is a framework for developing custom Programmable Block scripts for Space Engineers. It enables you to build interoperable modules to suit the specific needs of your ship or station. Mother OS is built with Mother Core and a collection of extension modules.

  • Common Activities
  • Overview
  • Recommended File Structure
  • The Program Wrapper
  • The Extension Module

Common Activities

  1. Installation
  2. Create a Module
  3. Create a Command
  4. Send a Message
  5. Delay an Action
  6. Retrieve a Block

Overview

Scripts built with Mother Core depend on the Program instance, and a collection of Core Modules. These core modules provide a wide range of functionality, including intergrid communication, event handling, and block management. Developers can add their own functionality via Extension Modules.

Recommended File Structure

A Module is the primary unit of functionality. Therefore modules should in most cases manage their own commands and events. This allows modules to be self-contained and reusable across different scripts. Mother Core and Mother OS observe the following file structure:

File Structure
/
├── Program.cs
├── thumb.png
├── Modules/
    ├── MissileGuidanceModule/
        ├── MissileGuidanceModule.cs
        ├── Commands/
            ├── LaunchCommand.cs
            ├── DetonateCommand.cs
        ├── Events/
            ├── MissileLaunchedEvent.cs
            ├── MissileDetonatingEvent.cs

The Program Wrapper

We use the existing Program wrapper created using MDK2, but with a few modifications that allow Mother to do her thing. We register our Modules in the constructor, and hook into the Save() and Run() methods to give Mother complete control.

partial class Program : MyGridProgram
{
    private Mother mother;

    // Program constructor
    public Program()
    {
        // Create the Mother instance
        mother = new Mother(this);

        // Register Extension Modules
        mother.RegisterModules(new List<IExtensionModule> {
            new DoorModule(mother),
            new LightModule(mother),
            new MissileGuidanceModule(mother),
            ...
        });
    }

    // Save before recompile or when triggered
    public void Save() {
        Storage = mother.Save();
    }

    // Run Mother each time the Program runs
    public void Main(string argument, UpdateType updateType) {
        mother.Run(argument, updateType);
    }
}

The Extension Module

You can add new functionality to the program by creating an Extension Module. These modules are registered in the Program constructor using the RegisterModules() method. They may access all other modules directly and respond to changes when other modules emit Events.

We will use the MissileGuidanceModule as our example. It provides functionality to launch and detonate missiles, and updates the thrusters on each program cycle.

MissileGuidanceModule.cs
class MissileGuidanceModule : BaseExtensionModule
{
    // Boot the module
    public void Boot()
    {
        // Reference important modules
        FlightPlanningModule = Mother.GetModule<FlightPlanningModule>();

        // Register custom terminal commands like 'detonate' and 'launch'
        RegisterCommand(new LaunchCommand(this));
        RegisterCommand(new DetonateCommand(this));

        // Load relevant blocks from the grid
        Thrusters = Mother.GetModule<BlockCatalogue>().GetBlocks<IMyThrust>();

        // Listen for events
        Subscribe<MissileLaunchedEvent>();
    }

    // Run module every program cycle
    public override void Run()
    {
        UpdateThrusters()
    }

    // Do something...
    void UpdateThrusters() { 
        Thrusters.ForEach(thruster => {
            // ...
        })
    }
}

As you can see, connecting logic with Modules is easy and most of it is done in the Boot() method.

Last Updated: 9/28/25, 8:12 PM
Contributors: Luke Morrison, lukejamesmorrison
Prev
Mother OS (Ingame Script)
Next
Installation