Verse - New to Persistable Data and getting errors

Hi, I’m trying to work persistable data into my map for the first time and I’m running into an error soon after typing up some code I saw in a tutorial or two. Can anyone point me to a right direction here, or if there’s posts about this already? I tried to search but haven’t found the same issue so far.

Definition (/dogonakeyboard@fortnite.com/iceGrapple/customVerse:)playerDataMap is accessible from subpaths of /dogonakeyboard@fortnite.com/iceGrapple, but depends on (/dogonakeyboard@fortnite.com/iceGrapple/customVerse:)Player_Data_Persistable, which is only accessible from subpaths of /dogonakeyboard@fortnite.com/iceGrapple/customVerse. The definition should be no more accessible than its dependencies.(3593)

My code for this is here so far in a file called Player_Data_Persistable.verse

using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }


# do not move / rename this file after publishing with it
var playerDataMap <public>: weak_map(player, Player_Data_Persistable) = map{}


Player_Data_Persistable := class<final><persistable>:
    # DO NOT RENAME VARIABLES ONCE PUBLISHED
    # DO NOT REMOVE VARIABLES ONCE PUBLISHED

    # Saved profile data for each player
    version : int = 0
    currency : int = 0
    totalWins : int = 0
    totalLosses : int = 0

    # Rank : int = 0


MakePlayerData <public><constructor>(Src:Player_Data_Persistable)<transacts> := Player_Data_Persistable:
    # fill in player's data when they load in
    version := Src.version
    currency := Src.currency
    totalWins := Src.totalWins
    totalLosses := Src.totalLosses

The issue you’re running into is related to Modules and Paths in Verse (here is the official documentation: https://dev.epicgames.com/documentation/en-us/fortnite/modules-and-paths-in-verse

In Verse, every folder you create automatically becomes a module, and any .verse files inside that folder belong to that module. The module name is the same as the folder name.

I’ve personally had some issues when defining an enum inside a folder/module and trying to use it outside of that module. Even when I marked the enum with the <public> specifier, I still ran into errors. As far as I remember, this happens because the module itself also needs to be public, but since modules are defined by folders, I haven’t found a clear or reliable way to explicitly mark a folder/module as <public>.

Because of this behavior, my recommendation is:
If you have data types that need to be shared across multiple modules or submodules (such as classes, enums, structs, etc.), define them in the root of the project, not inside a subfolder. This avoids visibility and import issues between modules.

So in short:

  • Folder = module

  • .verse files belong to that module

  • Making a type <public> is sometimes not enough if the module itself isn’t accessible

  • Shared types are safest when placed at the project root

Hopefully this helps clarify the issue :+1:

2 Likes