# How to create and use a module in Verse?

**URL:** <https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823>\
**Category:** Verse\
**Tags:** fortnite-creative, unreal-editor-for-fortnite, question, fortnite\
**Created:** [May 5, 2023, 12:32am UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823 "2023-05-05T00:32:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![poltrr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/poltrr/32/677016_2.png) [@poltrr](https://forums.unrealengine.com/u/poltrr)\
**Post date:** [May 5, 2023, 12:32am UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/1 "2023-05-05T00:32:25Z")

</div>

Hi,

I’d love to use modules to structure and logically group my scripts/classes. But I can’t seem to understand how to reference modules.

According to the docs, I can create a module by:

- Creating a folder.
- Creating a module inside a script by using `module()` instead of `class()`.

The problem comes when I want to use a module from scripts outside the module. I can’t seem to understand how to use the `using { / }` to reference custom modules. The autocomplete tells me that the path is `/Localhost/.../MyModule` but you can’t use Localhost in the path (for obvious reasons).

What am I missing here?

**\>\>\> EDIT \<\<\<**  
The answer by @1-UPProtocol is also a solution to my question (but I can only select one). So check it out, too!

---

<div class="post-metadata">

**Author:** ![1-UPProtocol](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/1-upprotocol/32/679214_2.png) [@1-UPProtocol](https://forums.unrealengine.com/u/1-UPProtocol)\
**Post date:** [May 5, 2023, 5:58am UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/2 "2023-05-05T05:58:23Z")

</div>

Hello, I struggled with this myself, but I found this is how to import custom modules. For example, say I create a custom module math\_module in a seperate verse file

```auto
# Custom Module I make with a Multiply function
math_module<public> := module:
    Multiply<public>(X : int , Y : int) : int =
        return X * Y

```

In my main Verse File, I would do

```auto
using {math_module}

OnBegin<override>()<suspends> : void =
    Product : int = math_module.Multiply(3, 5)
    Print(" 3 x 5 = {Product}")

```

Note: You must give the module the public specifier, along with every method / class you want to reference in another verse file. Also, both files should be in the same workspace

---

<div class="post-metadata">

**Author:** ![Tom.Noonan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tom.Noonan](https://forums.unrealengine.com/u/Tom.Noonan)\
**Post date:** [May 5, 2023, 10:41am UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/3 "2023-05-05T10:41:28Z")

</div>

If you have two verse files organized into `MyProject/Content/First.verse` and `MyProject/Content/MyModule/Second.verse`, you can access the contents of Second.verse by adding `using { MyProject.MyModule }` to the top of First.verse

---

<div class="post-metadata">

**Author:** ![t.tutiya](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/t.tutiya/32/924637_2.png) [@t.tutiya](https://forums.unrealengine.com/u/t.tutiya)\
**Post date:** [May 20, 2023, 8:25am UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/4 "2023-05-20T08:25:32Z")

</div>

@Tom.Noonan  
Hi. I followed your instructions to build the folder, but it didn’t work. Did I do something wrong?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/f/5/df52ff63aff8b62a8eca2c7bbd88ed90238f17cf.png)

---

<div class="post-metadata">

**Author:** ![Tom.Noonan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tom.Noonan](https://forums.unrealengine.com/u/Tom.Noonan)\
**Post date:** [May 22, 2023, 1:40pm UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/5 "2023-05-22T13:40:58Z")

</div>

You have entered `MyModuleub1` rather than `MyModule`

---

<div class="post-metadata">

**Author:** ![t.tutiya](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/t.tutiya/32/924637_2.png) [@t.tutiya](https://forums.unrealengine.com/u/t.tutiya)\
**Post date:** [May 22, 2023, 2:24pm UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/6 "2023-05-22T14:24:47Z")

</div>

@Tom.Noonan  
oh. very sorry. I was mistake. thank you

---

<div class="post-metadata">

**Author:** ![t.tutiya](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/t.tutiya/32/924637_2.png) [@t.tutiya](https://forums.unrealengine.com/u/t.tutiya)\
**Post date:** [May 22, 2023, 2:31pm UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/7 "2023-05-22T14:31:46Z")

</div>

@Tom.Noonan

Excuse me. One more question.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/5/e/35e7daa78ad5d7e435e748df30b810bdc9da3fb9.png)

Is this a specification? If so, why?

---

<div class="post-metadata">

**Author:** ![Knight\_Breaker](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/knight_breaker/32/1194711_2.png) [@Knight\_Breaker](https://forums.unrealengine.com/u/Knight_Breaker)\
**Post date:** [May 26, 2023, 12:35pm UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/8 "2023-05-26T12:35:32Z")

</div>

That seems to be somewhat a problematic setup as it forces you to use the project name. Can that be transparent? Last but not least, can you please comment on module exposure?! I found only a single buried reference to that, somewhere here on the forums during some private update announcement when modules were update.

My goal is to create a code structure like so, but I seem to fail somewhere, or the compiler isn’t able to understand it for some reason.

```auto
MyProject/Content/VerseSources/First.verse
MyProject/Content/VerseSources/Submodule1/A.verse
MyProject/Content/VerseSources/Submodule2/B.verse

```

- I would like be able to possibly reference `Submodule1` from `Submodule2` if they depend on each other in some way.
- I would like to reach `SubmoduleN` from `First.verse`.
- I would like to not being forced to use `MyProject` as a prefix.

The idea is to outsource `SubmoduleN` as standalone git repositories which I can commit to GitHub. That setup would allow me to properly re-use the modules in development across multiple projects instead of copy pasting them without any proper version control (UE version control simply does not cut here).

What is the proper way to make `SubmoduleN` public? IIRC it’s `MyProject/Content/VerseSources/Submodule1.verse` with some `module` macro being explicitly marked as `public`.

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![t.tutiya](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/t.tutiya/32/924637_2.png) [@t.tutiya](https://forums.unrealengine.com/u/t.tutiya)\
**Post date:** [May 27, 2023, 1:58am UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/9 "2023-05-27T01:58:52Z")

</div>

Hi. Here you are.

`MyProject/Content/VerseSources/Submodule1/A.verse`

 ![0526_0A](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/7/c/27ce0da7300e3e7c0463b2ee3b91a48dbc9e6aaf.png)

`MyProject/Content/VerseSources/Submodule2/B.verse`

 ![0526_0B](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/1/c1149fe64bb0f79b962783a5fed5c3692cb485f2.png)

`MyProject/Content/VerseSources/First.verse`

 ![0526_0First](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/8/4/e84c79a263746bdd93bafe580c89078f479c8e14.png)

Output  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/9/2/a92580906dbc17c2bf93a506e4ac5797e48745f8.jpeg)

---

<div class="post-metadata">

**Author:** ![AJ\_Lakeman](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aj_lakeman/32/770700_2.png) [@AJ\_Lakeman](https://forums.unrealengine.com/u/AJ_Lakeman)\
**Post date:** [May 31, 2023, 7:25pm UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/10 "2023-05-31T19:25:55Z")

</div>

How were you able to get the “Content” folder showing in your hierarchy there? Did you make one in addition to the one included with a project? e.g. Plugins/Project/Content/Content/VerseSources/ in windows explorer?

---

<div class="post-metadata">

**Author:** ![t.tutiya](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/t.tutiya/32/924637_2.png) [@t.tutiya](https://forums.unrealengine.com/u/t.tutiya)\
**Post date:** [June 6, 2023, 2:14am UTC](https://forums.unrealengine.com/t/how-to-create-and-use-a-module-in-verse/1154823/11 "2023-06-06T02:14:09Z")

</div>

@AJ_Lakeman  
Yes. " Content" is a folder with only the “VerseSoruces” folder.
