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 
3 Likes
Hmm ok I think I follow. I started this way because I was watching a tutorial, I think this video here at about 1:19, and he had his persistent data put into a sub folder in his project if I’m seeing that correctly.
I will have to try your suggestion to move the verse file with persistable data. I just didn’t know if there were more special quirks or requirements to this because it’s persistent.
I’m not sure I’m doing this right. I tried deleting the old file and adding a new verse file to the project in UEFN without it being in any subdirectories and it gives me a similar error. I copied and pasted the code but changed the name of the class a little bit.
Hey sorry for all these posts if it’s spamming but I think I found out something. For some reason declaring <public> on the functions and the map was the thing causing this error. I removed those and now they are compiling without error in the verse file that was moved to the root folder!
I think I can even move this folder back to the customVerse sub folder I have too now and it doesn’t seem to be throwing any errors yet. I have yet to use this data in other devices but I think I’m on my way now, thanks again for the help!