Mother DocsMother Docs
Buy me a Coffee
Steam Workshop
Discord
  • Mother OS (Ingame Script)
  • Mother GUI
  • Mother Autopilot System (MAPS)
  • Mother Core (Script Framework)
  • Cheatsheet
  • Brand Guidelines
Buy me a Coffee
Steam Workshop
Discord
  • Mother OS (Ingame Script)
  • Mother GUI
  • Mother Autopilot System (MAPS)
  • Mother Core (Script Framework)
  • Cheatsheet
  • Brand Guidelines
  • Cheatsheet
  • Mother OS (Ingame Script)
    • Getting Started

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

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

      • Air Vent Module
      • Battery Module
      • Terminal Block Module
      • Cockpit Module
      • Connector Module
      • Display Module
      • Door Module
      • Gas Tank Module
      • Hinge Module
      • Landing Gear Module
      • Light Module
      • Piston Module
      • Programmable Block Module
      • Rotor Module
      • Screen Module
      • Sensor Module
      • Sorter Module
      • Sound Block Module
      • Thruster Module
      • Timer Block Module
      • Wheel Module
    • Compatibility
    • Examples
  • Mother GUI
    • Getting Started

      • Installation
      • Configuration
    • Commands
    • Menus
    • Views
  • Mother Autopilot System (MAPS)
    • Getting Started

      • Upgrade Guide
      • Installation
    • Modules

      • Flight Planning Module
      • Map Module
      • Flight Control Module
      • Attitude Module
      • Docking Module
  • Mother Core (Script Framework)
    • Getting Started

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

      • Color Helper
      • Number Helper
      • Security
      • Serializer
    • Tutorials
  • Powered By Mother
  • Brand Guidelines

Activity Monitor

  • Registering a Block
  • Unregistering a Block
  • When to Reach for It
  • Emitted Events

ActivityMonitor is for one-shot completion tracking. Use it when a block should be watched until it reaches a terminal state, then cleaned up automatically.

If you need continuous state monitoring for an entire block type, prefer RegisterBlockTypeForStateMonitoring<T>() from BaseModule and let BlockCatalogue drive the checks.

Registering a Block

RegisterBlock() accepts:

  1. The block to watch.
  2. A predicate that returns true when the terminal state has been reached.
  3. A callback that runs once, right before the block is removed from monitoring.
HangarDoorModule.cs
public void ExtendRamp()
{
    IMyPistonBase piston = GetBlocksByName<IMyPistonBase>("Hangar Ramp")
        .FirstOrDefault();

    if (piston == null)
        return;

    piston.Enabled = true;
    piston.Velocity = 0.5f;

    GetModule<ActivityMonitor>().RegisterBlock(
        piston,
        block => ((IMyPistonBase)block).CurrentPosition >= 8f,
        block =>
        {
            var ramp = (IMyPistonBase)block;
            ramp.Velocity = 0;
            ramp.Enabled = false;
            Mother.Print("Ramp fully extended.");
        }
    );
}

Unregistering a Block

Call UnregisterBlock() if the activity is cancelled before the terminal state is reached.

HangarDoorModule.cs
public void AbortRamp()
{
    IMyPistonBase piston = GetBlocksByName<IMyPistonBase>("Hangar Ramp")
        .FirstOrDefault();

    if (piston == null)
        return;

    piston.Velocity = 0;
    GetModule<ActivityMonitor>().UnregisterBlock(piston);
}

When to Reach for It

Use ActivityMonitor when the lifecycle is:

  1. Start a block action.
  2. Wait until one condition becomes true.
  3. Run one callback.
  4. Stop watching that block.

That pattern is common for pistons, rotors, hinges, merge blocks, and connectors when you only care about the completion of a single action.

Emitted Events

ActivityMonitor does not emit any built-in events.

Last Updated: 5/2/26, 10:05 PM
Contributors: Luke Morrison, lukejamesmorrison, Copilot
Next
Almanac