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

Activity Monitor

  • Overview
  • Registering a Block
  • Unregistering a Block

Overview

The Activity Monitor's primary role is to track blocks that are changing continuously (ie. rotor moving to angle). Each program cycle, the activity monitor checks the state of each registered block, then unregisters it when the terminal state has been reached.

Registering a Block

To register a block, use the RegisterBlock() method. It takes the target block (IMyTerminalBlock) as it's first parameter. The second parameters is a function that determines if the block is at its terminal state (bool). The third parameter is an Action that will be executed when the terminal state is reached.

HingeModule.cs

public class HingeModule : BaseExtensionModule
{
    public void StartRotation(float targetAngle)
    {
        IMyMotorStator hinge = Mother.GetBlocksByName<IMyMotorStator>("Main Hinge").FirstOrDefault();

        Mother.GetModule<ActivityMonitor>().RegisterBlock(
            // The hinge block to monitor
            hinge,
            // Function to check if the hinge is at its terminal position
            block => HingeAtTerminalPosition(block as IMyMotorStator, targetAngle),
            // Action to execute when the hinge reaches its terminal position
            block => LockHinge(block as IMyMotorStator, true)
        );
    }
}

Unregistering a Block

If you wish to unregister a block before it has reached its terminal state, you can use the UnregisterBlock() method to stop monitoring immediately.

HingeModule.cs
public class HingeModule : BaseExtensionModule
{
    public void StopRotation()
    {
        IMyMotorStator hinge = Mother.GetBlocksByName<IMyMotorStator>("Main Hinge").FirstOrDefault();

        // Stop hinge motion and lock it
        hinge.TargetVelocityRPM = 0;
        hinge.RotorLock = true;

        // Stop monitoring the hinge
        Mother.GetModule<ActivityMonitor>().UnregisterBlock(hinge);
    }
}
Last Updated: 6/29/25, 10:09 PM
Contributors: Luke Morrison, lukejamesmorrison
Next
Almanac