How to communicate two different script verse files to each other.

Hi @DolphimDom:

The team has got a bit of work to do on documenting how Verse scoping works, but to answer your question directly, if you had the following Verse scripts within your project:

In hello_world_device.verse:

Foo():void=
    return

And another function in hello_world_device2.verse:

Bar():void=
    Foo()

This should already be compilable. If you hover over the Foo symbol in VS Code, the LSP should also show you the full Verse path of that function symbol:

(/localhost/_MyProjectC:)Foo():void

Behind the scenes, the Foo and Bar symbols are defined under your project’s Verse path, which helps avoid namespace collisions. You can wrap these functions into modules/classes to help encapsulate them further:

my_module := module:
    Foo<public>():void=
        return

In your other script file, you’d then need to first import your new module:

using { my_module }

And then you can again use the function as-is in Bar:

Bar():void=
    Foo()

This isn’t the only way to do things in Verse and is far from the full set of rules surrounding scoping, but hopefully that gives you a clearer idea of where to start. Please feel free to provide feedback on the documentation located at: https://www.epicgames.com/fortnite/en-US/creative/docs/uefn/Verse/modules-and-paths-in-verse regarding this subject.

2 Likes