skeldjs
    Preparing search index...

    Class SwitchSystem<RoomType>

    Represents a system responsible for handling switches in Electrical.

    See SwitchSystemEvents for events to listen to.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    actual: SwitchSetup = ...

    The current switch states.

    brightness: number = 255

    The brightness of lights.

    expected: SwitchSetup = ...

    The switch states that are expected.

    systemType: SystemType

    Accessors

    Methods

    • Invert the position of a switch.

      Parameters

      • num: number

        The ID of the switch to invert.

      • flippedByPlayer: Player<RoomType>

      Returns Promise<void>

      // Invert the position of each switch.
      for (let i = 0; i < 5; i++) {
      electrical.flip(i);
      }
    • Set the value of a switch as flipped or not flipped

      Parameters

      • num: number

        The ID of the switch to flip.

      • value: boolean

        Whether the switch is flipped.

      Returns Promise<void>

      // Randomise each switch.
      for (let i = 0; i < 5; i++) {
      electrical.setSwitch(i, Math.random() > 0.5);
      }
    • Read the value of each switch from a byte.

      Parameters

      • byte: number

        The byte to read from.

      Returns SwitchSetup

      An array of the value of each switch.

      console.log(readSwitches(0x5));
      // [ true, false, true, false, false ]
    • Write the value of each switch to a byte.

      Parameters

      • switches: SwitchSetup

        An array of the value of each switch.

      Returns number

      The byte representation of the switches.

      console.log(writeSwitches([ false, true, false, false, true ]));
      // 0x12 (18)