Hey :). A bit of an architecture issue here, so this is going to be a bit long by word count :).
I’m working on a game that I want to allow mods for (from now on referred to as Data Packs).
The mods will be written in haxe and deployed as JS libraries which I want to load inside the game using externs. I would have wanted haxelibs here but Haxe can’t load libs at runtime from what I know.
Because I don’t want to recompile the game engine every time a new Data Pack is added, the game instead refers to a Data Pack List. This CAN be recompiled and is where the Data Packs will be collected. Every time a new Data Pack is added, the idea is that this DataPackList is recompiled and it produces a larger JS file which is then referred to in the game via extern.
The current issue is that I can’t find a way to make Haxe to “unify” the Data Packs JS into the DataPackList JS. Even though DataPackList has an extern to a DataPack, the game crashes when the DataPackList tries to call a method on the DataPack (the DataPack doesn’t exist).
My ideal architecture, in a nutshell, is:
- the game, “Nexus”, which I seek to NOT recompile for every added mod.
- an SDK that is a haxelib and does not concern this question (but this is where DataPackBase is defined)
- a DataPackList project (which CAN be recompiled: the purpose of which being that HERE is where mods are added, as externs).
- the DataPacks (mods).
The Game Engine will have a static reference to the SDK.
All Data Packs will have to respect the type requirements of the SDK. This also means that mods don’t necessarily have to be written in Haxe. Modders can use JS as long as the data types can be used via the extern mapping.
The reason why JS/Haxe is required by the mods is because complex game-play logic may reside in the mod.