JohnWordsworth wrote:Re: Mod size. Having a version that fits on Steam is a must I think. We would miss out on a large number of players if we don't aim for that. I will have a think about a "friendly" way we could offer an "HD" version without it being too much manual work. Preferably, we can almost automate it (put your HD assets in a special folder and a script copies them into mod_assets using a python script).
Dungeon export will ignore files without certain extensions so you can simply have the script rename the unused assets.
Simple version: You could make the script swap out any files appended with HD (use "materials.lua" versus "materials.lua.HD"). Because Grimrock 2 supports external scripts, you could have a simple script entity that loads an external file "isHD.lua" versus "isHD.lua.HD". Then define an "HD" field in the HD version, and scripts across the game could use "if isHD.script.HD then" for mode-dependent behaviour. No manual file changes required to switch between the two. If we enforce that rooms keep all their files (object definitions etc) in their own folder, this would be quite simple to maintain.
Improved version: have the script set an "HD" variable in every Lua file that's loaded before script entities (except for dungeon.lua), then modders would get ifdef behaviour in their asset definitions (similar to how Config.getRenderingQuality() is used). This way you would only need one materials.lua and the file swapping would only be needed for actual binary assets.
EDIT: Here's a complete specification of what I have in mind:
- Two naming patterns for files would be used: "*.extension.HD", and "*.extension.LD". Obviously we don't have to use those specific acronyms or anything. The term "regular asset file" will heretofore refer to a file without a .HD or .LD extension.
- When you run the "make HD" script, it copies all *.lua.HD, *.model.HD, *.dds.HD, *.animation.HD, *.wav.HD, *.ogg.HD, *.ivf.HD files to the same filenames with the ".HD" suffix removed. "goat.model.HD" is copied to "goat.model". The original "goat.model.HD" still remains.
- The "make LD" script would behave the same way but with the LD naming pattern instead. In addition, if it finds a file with an HD version but no LD version, it deletes the regular asset file.
This works because dungeon export only exports filenames ending in .lua, .model, .dds, .animation, .wav, .ogg, and (as of recent patches) .ivf.
Asset files would then fall into one of 3 categories:
1. If your file is the same in both the LD and HD versions, you don't need to do anything; give it a regular filename. The script will ignore it completely.
2. If you have both an LD and HD version of an asset, make all changes to assetname.LD and assetname.HD and let the script overwrite the regular asset file.
3. If you have an asset that should only be present in the HD version, make all changes to assetname.HD and let the script overwrite the regular asset file (HD) or delete it (LD); don't make an assetname.LD.
Pretty simple to follow IMO. Remember that most files would be in category 1.
About the "ifdef-like" behaviour. I realized there's a ridiculously easy hack for that:
Step 1. Have a file called "stupidConfigHack.lua.HD" (or whatever) consisting of one line:
Step 2. And a corresponding "stupidConfigHack.lua.LD" that's a completely empty file:
Step 3. Have this at the top of your init.lua:
Code: Select all
import "mod_assets/scripts/stupidConfigHack.lua"
Now every script in asset definition files AND ingame can use:
Code: Select all
if Config.HD then
-- do stuff for the HD version
else
-- do stuff for the LD version
end
Yes, it works with saving/loading the game!
Credit to JKos for being GODDAMNED INSANE enough to try adding fields to the global tables in the first place
The advantage of this is it doesn't require another level of automation - the script only has to do the file-moving - and plus it's really easy for scripters to type. The disadvantage is how dirty it feels.