# Creating a "Scripting Module" using Maven. Documentation?

**URL:** <https://forum.inductiveautomation.com/t/creating-a-scripting-module-using-maven-documentation/96608>\
**Category:** Module Development\
**Tags:** perspective, vision\
**Created:** [September 30, 2024, 1:58pm UTC](https://forum.inductiveautomation.com/t/creating-a-scripting-module-using-maven-documentation/96608 "2024-09-30T13:58:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MG3](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mg3/32/84125_2.png) [@MG3](https://forum.inductiveautomation.com/u/MG3)\
**Post date:** [September 30, 2024, 1:58pm UTC](https://forum.inductiveautomation.com/t/creating-a-scripting-module-using-maven-documentation/96608/1 "2024-09-30T13:58:30Z")

</div>

Hi all,

Looking to create a module that purely introduces new methods and classes for the Jython Scripting part of Ignition.

I have looked through the SDK Programmers Guide and can't see much information on this. So the questions I have are:

1. Will I need to use a different Maven Archetype to create this module? Currently, using the "vision-component-archetype". I assume it would be the `client-designer-gateway-archetype`?

2. Is there any documentation on how script like this is implemented? Currently, will be creating scripts that runs in the client scope (the script will be used in Vision), but knowing how to create a module that will work on perspective and be able to use both Gateway and Client Scopes would be interesting.

3. I assume the documentation includes some examples. But if not, if anyone has any idea where there are some examples showing some examples it will be appreciated.

Thanks! I look forward to your responses,

MG3

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 30, 2024, 2:24pm UTC](https://forum.inductiveautomation.com/t/creating-a-scripting-module-using-maven-documentation/96608/2 "2024-09-30T14:24:02Z")

</div>

Check out [ignition-sdk-examples/scripting-function at master · inductiveautomation/ignition-sdk-examples · GitHub](https://github.com/inductiveautomation/ignition-sdk-examples/tree/master/scripting-function)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 30, 2024, 4:57pm UTC](https://forum.inductiveautomation.com/t/creating-a-scripting-module-using-maven-documentation/96608/3 "2024-09-30T16:57:31Z")

</div>

> [@MG3](#):
>
> - Will I need to use a different Maven Archetype to create this module? Currently, using the "vision-component-archetype". I assume it would be the `client-designer-gateway-archetype`?

I wouldn't restrict yourself to learning how things work by sticking too closely to our (effectively abandoned) archetypes. The scopes your module supports are a function of the defined **Maven** modules and the module plugin configuration:

> <https://github.com/inductiveautomation/ignition-sdk-examples/blob/276f89239073e2108253716bce7f4ff70d20698d/scripting-function/scripting-function-build/pom.xml#L54-L72>

You will want to understand how these things fundamentally glue together.

> [@MG3](#):
>
> - Is there any documentation on how script like this is implemented? Currently, will be creating scripts that runs in the client scope (the script will be used in Vision), but knowing how to create a module that will work on perspective and be able to use both Gateway and Client Scopes would be interesting.

There might be a fundamental disconnect in your understanding here.  
The "scope" of a script really means "which JVM is it being run by", which will exclusively be one of the following:

1. Gateway
2. Designer
3. Vision client

There's really no independent Perspective scope - it's just the gateway scope, but with some thread-local context implicitly defined that allows the `system.perspective` functions to work without qualification.

Your module can opt-in to providing scripting functions to the platform by overriding the [`initializeScriptManager`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.43/com/inductiveautomation/ignition/gateway/model/GatewayModuleHook.html#initializeScriptManager(com.inductiveautomation.ignition.common.script.ScriptManager)) call. **Ignition** will call this function, automatically, in the platform, when constructing new ScriptManager instances, to allow modules to add their own extensions to the system function namespace.

If you _choose_ to provide a client scoped scripting function that is capable of, or requires, communication with the gateway, you've entered the world of RPC, which is (somewhat confusingly) tangled up in the example module Kevin linked above, but it is by no means a **requirement** to have a client scoped scripting function.

You can easily define scripting function logic that will be run on the local JVM and just introduce it in each respective module hook, e.g.

> <https://github.com/IgnitionModuleDevelopmentCommunity/ignition-extensions/blob/5aba12e3f5b891a4feca3fb311aa5840f40d76b9/common/src/main/java/org/imdc/extensions/common/UtilitiesExtensions.java#L50-L57>

> <https://github.com/IgnitionModuleDevelopmentCommunity/ignition-extensions/blob/5aba12e3f5b891a4feca3fb311aa5840f40d76b9/gateway/src/main/kotlin/org/imdc/extensions/gateway/GatewayHook.kt#L44-L51>

> <https://github.com/IgnitionModuleDevelopmentCommunity/ignition-extensions/blob/5aba12e3f5b891a4feca3fb311aa5840f40d76b9/client/src/main/kotlin/org/imdc/extensions/client/ClientHook.kt#L38-L44>

The specific process of exposing Java methods and objects to Jython is complicated and full of subtleties that are hard to cover concisely.

---

<div class="post-metadata">

**Author:** ![MG3](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mg3/32/84125_2.png) [@MG3](https://forum.inductiveautomation.com/u/MG3)\
**Post date:** [October 1, 2024, 3:27pm UTC](https://forum.inductiveautomation.com/t/creating-a-scripting-module-using-maven-documentation/96608/4 "2024-10-01T15:27:59Z")

</div>

Huge thanks @paul-griffith and @Kevin.Herron, looked through all that has been sent and this thread contains a lot of useful information. I hope it can help others as much as it has helped me!
