---
title: "Add a Module"
description: "How to add a module to LumiScan Script Runner: copy the procedure, add an entry to the application file, accept its interface hash and restart."
product: "LumiScan Script Runner"
component: "lumiscan-script-runner"
version: "1.0.0"
display_version: "1.0.0.2"
latest_version: true
language: "en"
url: "https://docs.hdvisionsystems.com/en/lumiscan-script-runner/how-tos/add-a-module.html"
---

# Add a Module – LumiScan Script Runner

A module runs one procedure and gets its own nodes under `v1/<module>/`. This guide adds a module `find` that runs a procedure `find_pattern`.

You need a procedure prepared as described in [Prepare a HALCON Procedure](https://docs.hdvisionsystems.com/en/lumiscan-script-runner/how-tos/prepare-a-procedure.html).

## 1. Copy the procedure

Copy `find_pattern.hdvp`, and its interface file `find_pattern.interface.json` if it has one, into the script folder, see [Settings Folder](https://docs.hdvisionsystems.com/en/lumiscan-script-runner/settings-folder.html#location). Copy any file the procedure reads there too.

## 2. Add the module to the application file

Open `lumiscan-script-runner.json` in the settings folder and add an entry to `modules`:

```json
{
    "name": "find",
    "procedure": "find_pattern",
    "trigger": "handshake"
}
```

- `name` is the module’s name on the Data Layer: lower case, only `a-z`, `0-9`, `-` and `_`. `system`, `api-version` and `v` followed by digits are reserved.
- `procedure` is the file name without `.hdvp`.
- Without `inputs` and `outputs` every value and image parameter gets a node. To give a parameter a fixed value, or to take it from the group’s store, add a binding, see [Bindings](https://docs.hdvisionsystems.com/en/lumiscan-script-runner/application-file.html#bindings).
- Without `group` the module is a group of its own. Modules that share a model go into one group, see [Share a Model Between Scripts](https://docs.hdvisionsystems.com/en/lumiscan-script-runner/how-tos/share-a-model-between-scripts.html).

Alternatively write the whole application file to `v1/system/settings` over the Data Layer: it is checked and saved, and `v1/system/restart-required` turns `true`.

## 3. Start the app and read the interface hash

1. Restart LumiScan Script Runner.

2. Read `v1/find/status/code`. Expected: `-10005`. A new module has no accepted interface hash yet, so its nodes are not built; `status/text` says so.

   If the code is `-10002` instead, the procedure did not load or its interface cannot be mapped: `status/text` names the parameter. Correct the procedure or its interface file, then restart. See [Troubleshooting](https://docs.hdvisionsystems.com/en/lumiscan-script-runner/troubleshooting.html#ts-script-not-loaded). When the text says a parameter `has no type`, write an interface file from the shape `script/interface` shows, see [Writing one from the procedure’s shape](https://docs.hdvisionsystems.com/en/lumiscan-script-runner/interface-file.html#from-the-shape).

3. Read `v1/find/script/interface`. Check the parameters, their types and where the types come from (`typeSource`).

4. Read `v1/find/script/interface-hash`, for example `sha256:4f1c…`.

## 4. Accept the interface

The accepted hash says: *this is the interface my PLC program is written for*.

1. Copy the hash into the module’s entry:
   ```json
   {
       "name": "find",
       "procedure": "find_pattern",
       "trigger": "handshake",
       "acceptedInterfaceHash": "sha256:4f1c…"
   }
   ```
2. Restart the app.
3. Read `v1/find/status/code`. Expected: `0`. The module’s input and output nodes are under `v1/find/run/`.

Note the accepted hash in your PLC project. Your PLC program can compare it with `v1/find/script/accepted-interface-hash` at its start.

## 5. Test the module

Run it once with the `run` handshake, as in [Run Your First Script](https://docs.hdvisionsystems.com/en/lumiscan-script-runner/how-tos/run-your-first-script.html). Then connect your PLC function block, see [The run Handshake](https://docs.hdvisionsystems.com/en/lumiscan-script-runner/run-handshake.html).

## Removing a module

Delete its entry from `modules` and restart the app. Its nodes are gone after the restart. The procedure file can stay in the script folder.
