Addin support for player mods

I’ve been tasked with adding support for player mods to the desktop version of our OpenFL game.

From what I can tell, asset file names are added to a manifest JSON and these are the assets that are available for the game to load.

So additional files made by our players won’t load just by dropping them into the asset directories, correct?


You can do this. For release I embed all my assets, but for testing level design I don’t embed the data files so they end up in assets/data folder and I can copy new files in there and they work. You can do the same with images or other assets.

This is my usage, but you can probably just set embed="false" for player mod assets.

<section if="windows">
	<assets path="assets/data" include="*.*" embed="false" if="dev" />
	<assets path="assets/data" include="*.*" embed="true" unless="dev" />

Then I use -D dev when building when I don’t want to embed my data files in the exe, for testing.

So really it’s just a matter of not embedding the files.

I figured that’s how it should be, but that’s not what happens when I set embed to false.

Our project XML has a “hero” folder with “embed=false”. In it are some character portraits, where each character has their own folder. I went to my windows/bin and directly added some folders and files so that there’s a “hero/testHero/full_portrait.png” so that it’s not in the manifest generated by the build. I modified our test class to check if the asset exists and it could not find it.

I think you want to have the asset tags in project.xml add the folders when building. Maybe it won’t create the folders if they’re empty? Try adding dummy default files so when it build it has files. If the build doesn’t create the folders, it won’t find them.

I created a “mods” folder with an empty “mods/mods.txt” and that got added to the build just fine. I then put a “test.txt” in the bin/windows/mods folder and updated my test code. It still couldn’t find the file.

So I think my original theory still holds; all asset files, embedded or not, are added to the manifest and anything not listed there can’t be loaded by the Assets class.

Seems like I’ll have to use Haxe’s regular file system to load user mods, be it from the game install directory or the player’s application directory.

ah, I see. The files added have to match the file names that you build with. So I think you can do it if you use a naming convention that uses the same file name. For what I was doing, I already had the same files (names) compiled in, and copied over them, so they were in the manifest.

Maybe you can edit the manifest after to include the files as they are added? Not sure if that works, though.

I probably could modify the manifest file, but by the looks of it the list of files is one very long URL encoded string with extra data added for each file. It’d require a deep dive into finding out how to parse it and I’m not sure it’d be worth it in the end. I’d rather find another way.

Thank you for your help, though! It is much appreciated :slight_smile:

1 Like

Another API can be used:

1 Like

Ah, yes, this looks quite useful. I’ll mess around with this tomorrow. Thank you!