# How to use a function from a custom module in creative device?

**URL:** <https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, module, function, editor, question, fortnite\
**Created:** [March 12, 2025, 8:56pm UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222 "2025-03-12T20:56:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrDJ2U](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrDJ2U](https://forums.unrealengine.com/u/MrDJ2U)\
**Post date:** [March 12, 2025, 8:56pm UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222/1 "2025-03-12T20:56:36Z")

</div>

I’m not sure what the problem is in the way I’m using modules. I’ve researched for awhile and can’t find anything that really explains it.

I have created the following module for the purpose of cycling vending machines. ( all of this is done because you can’t turn vending machine’s cycle ability to off…) and I don’t want to clutter up my other code where I want to actually cycle these vending machines.

I don’t know if I created this module correctly and if it needs to have a class or not. I’m not sure how I’d edit the editables actually if it’s not a device that’s in the level. I might have to just make to creative devices now that I think about it. can modules have editables? Please review the code and answer my questions if you can.

````using
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

VendingModule<public> := module:
    vending_manager := class(creative_device):
        @editable
        CastleTransform : transform = transform{
            Translation := vector3{X := 100.0, Y := 200.0, Z := 0.0},
            Rotation := MakeRotationFromYawPitchRollDegrees(YawRightDegrees := 0.0, PitchUpDegrees := 0.0, RollClockwiseDegrees := 0.0),
            Scale := vector3{X := 1.0, Y := 1.0, Z := 1.0}
        }

        @editable
        IceHouseTransform : transform = transform{
            Translation := vector3{X := 300.0, Y := 200.0, Z := 0.0},
            Rotation := MakeRotationFromYawPitchRollDegrees(YawRightDegrees := 0.0, PitchUpDegrees := 0.0, RollClockwiseDegrees := 0.0),
            Scale := vector3{X := 1.0, Y := 1.0, Z := 1.0}
        }

        @editable
        IceChairTransform : transform = transform{
            Translation := vector3{X := 500.0, Y := 200.0, Z := 0.0},
            Rotation := MakeRotationFromYawPitchRollDegrees(YawRightDegrees := 0.0, PitchUpDegrees := 0.0, RollClockwiseDegrees := 0.0),
            Scale := vector3{X := 1.0, Y := 1.0, Z := 1.0}
        }

        @editable
        ArcticTransform : transform = transform{
            Translation := vector3{X := 700.0, Y := 200.0, Z := 0.0},
            Rotation := MakeRotationFromYawPitchRollDegrees(YawRightDegrees := 0.0, PitchUpDegrees := 0.0, RollClockwiseDegrees := 0.0),
            Scale := vector3{X := 1.0, Y := 1.0, Z := 1.0}
        }
        
        @editable
        var CastleVMs : []vending_machine_device = array{}
        @editable
        var IceHouseVMs : []vending_machine_device = array{}
        @editable
        var IceChairVMs : []vending_machine_device = array{}
        @editable
        var ArcticVMs : []vending_machine_device = array{}

        # Transform to send the vending machine to when 'hiding'
        @editable
        var HideTransform : transform = transform{
            Translation := vector3{X := 0.0, Y := 0.0, Z := -1000.0},
            Rotation := MakeRotationFromYawPitchRollDegrees(YawRightDegrees := 0.0, PitchUpDegrees := 0.0, RollClockwiseDegrees := 0.0),
            Scale := vector3{X := 1.0, Y := 1.0, Z := 1.0}
        }

        SpawnVendingMachines(Wave: int)<decides><transacts>: void =
            if (Wave < 4 and Wave > 0 and Wave < CastleVMs.Length):
                # Remove current vending machines
                CastleVMs[Wave -1].TeleportTo[HideTransform]
                IceHouseVMs[Wave-1].TeleportTo[HideTransform]
                IceChairVMs[Wave-1].TeleportTo[HideTransform]
                ArcticVMs[Wave-1].TeleportTo[HideTransform]
                
                # Bring in next round of vending machines
                CastleVMs[Wave].TeleportTo[HideTransform]
                IceHouseVMs[Wave].TeleportTo[HideTransform]
                IceChairVMs[Wave].TeleportTo[HideTransform]
                ArcticVMs[Wave].TeleportTo[HideTransform]```

I want to be able to call this 'SpawnVendingMachines()' function in another class.
````

---

<div class="post-metadata">

**Author:** ![btwixer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@btwixer](https://forums.unrealengine.com/u/btwixer)\
**Post date:** [March 12, 2025, 11:25pm UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222/2 "2025-03-12T23:25:58Z")

</div>

I’ll try and answer, but I’m not sure I’m fully understanding the question.

I can see from this line of code that the verse file represent a device, not just a class - as you said it does.

```auto
    vending_manager := class(creative_device):

```

After compiling this code, did you get a new device representing it in the UEFN browser? They appear at the top level under your project name.

Did you drag and drop that device into the world - in the UEFN editor? So you’ll have something like this now for the device?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/e/1/7e1b8defd7dbb34e05d55e0d28a7cb2b9bbfeaf2.jpeg)

If so, at this point you’ve created an instance of your new device in the game - it will start when the game starts.

If you want some other Verse device to have access to this Verse device instance, you need to use an editable there as well.

Let’s say the second device is called another\_device, it might look something like this.

```auto
another_device := class(creative_device):

    # This can be used for another_device to get access to the instance of vending_manager that you placed in the world.
    @editable IN_Vending_Manager : vending_manager = vending_manager{}

```

After compiling the Verse code again, you’d need to add the second device from the browser into the world (the another\_device one). Then click on this new device instance in the world and you can set the IN\_Vending\_Manager editable to your first device.

Hope it helps.

---

<div class="post-metadata">

**Author:** ![MrDJ2U](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrDJ2U](https://forums.unrealengine.com/u/MrDJ2U)\
**Post date:** [March 13, 2025, 1:27am UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222/3 "2025-03-13T01:27:06Z")

</div>

I understand that and I think I’ve done something like that before but at first I thought I didn’t need it.

How would I just use a function from a module is what I was trying to figure out but the way I’ve written this module, it is a creative\_device with it’s own editables. So i’d have to go your method. But I’ll have to change it from being a module and just a creative device I think because I’m getting this error.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/3/2935ac1b8704a735225225ee7f8ca379c23f3fe7.png)

---

<div class="post-metadata">

**Author:** ![btwixer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@btwixer](https://forums.unrealengine.com/u/btwixer)\
**Post date:** [March 13, 2025, 2:41am UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222/4 "2025-03-13T02:41:53Z")

</div>

A standalone function can be used anywhere in the module as far as I know (a function not in a class or device).

A function that is part of a class, you can create an instance of that class, and then call the function anywhere.

```auto
myVariable : my_class = my_class{}

myVariable.SomeFunctionInMyClass()

```

But devices are different, they are made to be added to the game world, and the game creates and starts them (well, each instance added to the game world).

It really depends on what the function needs to do, and how it can/needs to fit in with the rest of the code.

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [March 13, 2025, 9:48am UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222/5 "2025-03-13T09:48:59Z")

</div>

Making a public module isn’t enough to make everything public inside the module, you need to do the following :

```auto
VendingModule<public> := module:
    vending_manager<public> := class(creative_device):

```

Everything inside a module is internal by default, unless you specify otherwise  
I believe by making the module public, you’re only making it “importable” from anywhere

---

<div class="post-metadata">

**Author:** ![MrDJ2U](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrDJ2U](https://forums.unrealengine.com/u/MrDJ2U)\
**Post date:** [March 13, 2025, 2:52pm UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222/6 "2025-03-13T14:52:25Z")

</div>

Ok but how to import it?

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [March 13, 2025, 3:05pm UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222/7 "2025-03-13T15:05:02Z")

</div>

using { VendingModule }

---

<div class="post-metadata">

**Author:** ![MrDJ2U](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrDJ2U](https://forums.unrealengine.com/u/MrDJ2U)\
**Post date:** [March 13, 2025, 3:46pm UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222/8 "2025-03-13T15:46:29Z")

</div>

> [@MrDJ2U](#):
>
> ```auto
> VendingModule<public> := module:
> 
> ```

hmmmmmmm… thank you! So a few things. I was reading or misreading maybe that I had to import the path? But what you suggested finally doesn’t give errors. I thought I tried that. It works regardless of if the module is public or not. So could you clarify by importable from _anywhere_? Could you import it? Could I import it into another project? Or is it just different folder hierarchy within my project? Any clarification anyone could give would be great.

I see that if I want editables, I need to create a class and then an instance of that and get a reference to that device instance and call it’s properties in the way I have it set up. So is there any point to me having this in a module? It seems to work as just a class.

So I guess I have failed to use a module correctly because I wanted editables and if I remove the class line then I get errors about “This invocation calls the ‘reads’ effect…” so I’ll just use it as a class.

Edit: I’ve tinkered and found out that nothing needs to be public if you get an instance of that device(or probably just class too) and then call the functions on that instance. Which makes sense but I haven’t found a good use of `<public>` yet so I’m still a little confused on when to use it. You all have pointed out some interesting things about it though.

But I think I understand modules and how to use them a little bit better now. I probably could rewrite it to not have editables and only use gameplay tags but I need more granularity over which array element is in which slot, thus picking them from the scene/list is the better option here.

I’ll use a module soon! I’m determined. If anyone knows of any good snippets that would help me understand this I would appreciate it. @btwixer and @im_a_lama, you’ve both been a great help. I really appreciate it!

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [March 13, 2025, 3:50pm UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222/9 "2025-03-13T15:50:02Z")

</div>

There’s no point in using modules, it’s just used for file structuring and managing property/method access more accurately

Would be hard to explain what I said earlier, you’d need to experiment with modules for that

---

<div class="post-metadata">

**Author:** ![btwixer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@btwixer](https://forums.unrealengine.com/u/btwixer)\
**Post date:** [March 13, 2025, 4:12pm UTC](https://forums.unrealengine.com/t/how-to-use-a-function-from-a-custom-module-in-creative-device/2387222/10 "2025-03-13T16:12:11Z")

</div>

I’ve got several devices and a bunch of classes, I’ve ignored modules so far, likely UEFN created a module for me and all my code is in that module.

I only use devices when I need one or more editables - and almost all of those are in my ‘resource manager’ device, so I have one place for most things that need to be populated in the game world but used in Verse. My other classes then call a resource manager function to get ‘their’ editables.

I tried using gameplay tags shortly after they came out, but at point that they mostly worked but didn’t seem to be reliable enough, so for now I’m not using them. But if they are reliable they’re a great option in my view.

I have cases where I need editables to be paried - such as custom props and their respective prop managers. At this point I do that by hand, I have an editable array for each and I put them in the array in the same order (prop 1, prop 2, prop3 …) and (propMan 1, propMan 2, propMan 3 …).

Previously when I used gameplay tags I matched them up based on their location (transform), for each prop I checked all the unmatched propMan’s for the one that is within a small area of the prop. That worked well and was less tedious than my current approach. 🙂

There’s tons of different ways to write and organize code … partly it’s for maintainability / clarity / efficiency … partly it’s just style / personal choice.
