“Priority Stack”? What is a “Priority Stack”?
Definition
Priority Stack is probably a misleading name, but the PS (Priority Stack) is just an ordered array of directories in the VFS (Virtual File System). (This is the name I came up with, feel free to correct me/msg me about it on my email, since this concept wasn’t invented by me)
The stack will typically look something like this:
mods/cool-mod/mods/even-cooler-mod/mods/**base_game/
Why is this useful? And how does it even work?
How
Imagine that the game requests textures/enemy_sprite.png and there’s an active mod that has a modified version of this asset.
The VFS will traverse through the PS and search in each directory until it finds the asset, returns it and stops searching through the PS.
Conceptually, each entry in the PS is a container where the game can find its assets, whether that container is a folder or a packed file.
Why
The default assets (the base game’s) are always last on the PS. This way, if any mod replaces an asset, it’s sure to be loaded instead of the unmodified asset. This is the biggest benefit of the Priority Stack! Replacing assets! This is not only extremely useful during development but it also makes modding a game much easier!
- You won’t have to directly replace the game’s assets in a destructive way.
- If the game uses packed assets, modders won’t need to use the same packed structure, they can ship mods in their preferred format (Which, for example, contributes to mods not weighing more than they should)
All in all, a PS is definitely a good inclusion if you plan to add modding to your engine.
Goodbye
I think I’ve sold you on using a Priority Stack now. See you next time!