> ## Documentation Index
> Fetch the complete documentation index at: https://lationscripts.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Modern UI - Signal Breach

> Interactive hacking mini-game with configurable difficulty and progression

## Quick Start

```lua theme={null}
local success = exports.lation_ui:signalBreach('Hack Terminal', 'medium', 'E')

if success then
    print('Success')
else
    print('Failed')
end
```

## Functions

<AccordionGroup>
  <Accordion title="signalBreach" icon="signal">
    Start an interactive signal breach hacking mini-game.

    ```lua theme={null}
    local success = exports.lation_ui:signalBreach(title, difficulty, inputs, options)
    ```

    **Parameters:**

    * `title` (string, optional) - Title for the signal breach
    * `difficulty` (string | table, required) - Difficulty level or custom config object (see [Difficulty Levels](#difficulty-levels))
    * `inputs` (string | table, optional) - Single input key or array of input keys (default: `'E'`)
    * `options` (table, optional) - Additional options (see [Options](#options))

    **Returns:**

    * `success` (boolean) - `true` if the signal breach was completed successfully, `false` if failed or cancelled
  </Accordion>

  <Accordion title="cancelSignalBreach" icon="xmark">
    Cancel the currently active signal breach.

    ```lua theme={null}
    exports.lation_ui:cancelSignalBreach()
    ```
  </Accordion>

  <Accordion title="signalBreachActive" icon="circle-question">
    Check if a signal breach is currently active.

    ```lua theme={null}
    local isActive = exports.lation_ui:signalBreachActive()
    ```

    **Returns:**

    * `isActive` (boolean) - `true` if a signal breach is active, `false` otherwise
  </Accordion>
</AccordionGroup>

## Configuration

### Options

<ParamField path="title" type="string">
  Title displayed for the signal breach
</ParamField>

<ParamField path="difficulty" type="string | table" required>
  Difficulty level or custom difficulty object

  See [Difficulty Levels](#difficulty-levels) for available options
</ParamField>

<ParamField path="inputs" default="E" type="string | table">
  Single input key or array of input keys
</ParamField>

<ParamField path="options.speedIncrease" type="number">
  Amount to increase the indicator speed after each successful node (e.g. `0.08`)
</ParamField>

<ParamField path="options.windowDecrease" type="number">
  Amount to shrink the target window after each successful node (e.g. `2`)
</ParamField>

<ParamField path="options.failOnWrongKey" type="boolean">
  If `true`, pressing the wrong key immediately fails the breach (default: `false`)
</ParamField>

<ParamField path="options.onNode" type="function">
  Callback fired after each node attempt

  ```lua theme={null}
  onNode = function(node, success)
      -- node: number (1-based index of the completed node)
      -- success: boolean (whether the node was hit)
  end
  ```
</ParamField>

### Difficulty Levels

<Tabs>
  <Tab title="Preset Difficulties">
    Use predefined difficulty levels for quick setup.

    <ParamField path="easy" type="string">
      3 nodes, large window, slow speed
    </ParamField>

    <ParamField path="medium" type="string">
      4 nodes, medium window, medium speed
    </ParamField>

    <ParamField path="hard" type="string">
      5 nodes, small window, fast speed
    </ParamField>

    **Example:**

    ```lua theme={null}
    -- Single difficulty
    local success = exports.lation_ui:signalBreach('Hack Terminal', 'easy', 'E')

    -- Hard with progression ramp
    local success = exports.lation_ui:signalBreach('Bypass Firewall', 'hard', {'W', 'A', 'S', 'D'}, {
        speedIncrease = 0.08,
        windowDecrease = 2,
    })
    ```
  </Tab>

  <Tab title="Custom Difficulty">
    Create custom difficulty configurations with precise control.

    <ParamField path="nodes" type="number">
      Number of nodes to complete (1–20)
    </ParamField>

    <ParamField path="windowSize" type="number">
      Size of the target window as a percentage of the bar width (3–80)
    </ParamField>

    <ParamField path="speed" type="number">
      Speed of the indicator in units per frame at \~60fps (0.05–2)
    </ParamField>

    **Example:**

    ```lua theme={null}
    -- Custom difficulty object
    local success = exports.lation_ui:signalBreach('Crack Encryption', {
        nodes = 6,
        windowSize = 22,
        speed = 0.40
    }, 'E', {
        speedIncrease = 0.06,
        windowDecrease = 2,
        onNode = function(node, success)
            print(('Node %d: %s'):format(node, success and 'Hit' or 'Miss'))
        end
    })
    ```
  </Tab>
</Tabs>

## Preview

<Frame>
  <img src="https://mintcdn.com/lationscripts/Ti0acW9JT3q4BC3Y/resources/modern-ui/components/signal-breach/example.webp?fit=max&auto=format&n=Ti0acW9JT3q4BC3Y&q=85&s=0559734393c599a7603ece2837ffd80f" alt="Signal Breach Example" width="976" height="620" data-path="resources/modern-ui/components/signal-breach/example.webp" />
</Frame>
