Expansions Folder File Ref
-
If I want a reference to a specific Expansion folder, how do I go about getting it? This will be outside of a plugin, so there won't be an active expansion and no expansion wild cards. I basically want an absolute path. Can I add to the code below or can I use fromAbsolutePath (seems like this is for getting a file rather than saving which is what I want to do).
var ex = FileSystem.getFolder(FileSystem.Expansions);
var ad = FileSystem.getFolder(FileSystem.Expansions/mynewexpansion);
-
@DanH You can use
.getChildFile()
to get any file or directory within another directory. -
@d-healey so it would be
var ad = FileSystem.getFolder(FileSystem.Expansions); var bd = ad.getChildFile("mynewexpansion");
?
-
-
@d-healey it's not written in the docs but it is available as an option in the script editor's autocomplete menu (along with a few others IIRC)
-
-
@d-healey I've been testing and I can't write a file to the Expansions folder in AppData so it looks like it's not suitable for my purpose here. I've ended up doing a rather long-winded way of getting to my folder in my expansion - is there not a better way?!
const AD = FileSystem.getFolder(FileSystem.AppData); const EXP = AD.getChildFile("Expansions"); const NE = EXP.getChildFile("New Expansion"); const SAM = NE.getChildFile("Samples"); const f = SAM.getChildFile("New File.txt"); f.writeString("aaarrrggghhhh!!!");
-
@DanH What's wrong with
expansion.getRootFolder().getChildFile("Samples/New File.txt");
? -
@Christoph-Hart I guess because I won't be in an active expansion. I'm making an installer for an expansion and trying to write the link file into the correct folder (without using HR1 files).
But can I just go
const EXP = AD.getChildFile("Expansions/New Expansion/Samples");
?
-
@DanH If the expansion doesn't exist, I would prefer your solution from above:
var ad = FileSystem.getFolder(FileSystem.Expansions); var bd = ad.getChildFile("mynewexpansion");
The expansion folder might be redirected to somewhere else, so this might not work in every use case.
-
Also you can drop the samples of the expansion in the Sample folder and they will be loaded just fine, this keeps them all in one place.
-
@Christoph-Hart said in Expansions Folder File Ref:
Also you can drop the samples of the expansion in the Sample folder and they will be loaded just fine, this keeps them all in one place.
Yep, but user feedback was very much that they want full control over where they are stored
I created the expansion folder in the AppData/Expansions folder, but I couldn't write a file using
var ad = FileSystem.getFolder(FileSystem.Expansions); var bd = ad.getChildFile("mynewexpansion");
-
@DanH
getChildFile()
doesn't write files. You need to usecreateDirectory()
-
@d-healey I know I meant I can't get to the right folder using that code