Define how mods with scripts should be handled
There are two types of scripts that mods can come with:
- scripts that should be generally available regardless of whether the mod is "active" for a world
- scripts that depend on changes to the raws and should only be accessible if the mod is active
I think that we should define a directory format for mod authors to follow so we can handle them appropriately. A mod can come with both types of scripts, so it stands to reason that they could be identified by directory name. For example:
-
general_scripts/could hold scripts that should always be in the script path, regardless of whether the mod is active -
active_scripts/could hold scripts that should only be in the script path if the mod is active
at dfhack init, we can scan for general_scripts/ directories and add them all to the script paths, maybe after hack/scripts so mods can't hijack a standard script, accidentally or intentionally
on world load, we can check the active mod list and append relevant active_scripts/ directories to the script paths
We should decide on a standard soon to reduce the mounting confusion about how this should be handled.
scripts/general and scripts/active would also work, but people may be confused if the top scripts/ directory itself is not in the script path
or scripts/always instead of scripts/general?
people may be confused if the top
scripts/directory itself is not in the script path
That's true, considering df copy the mod in a mods_active folder, "scripts_active" (or "scripts_modactive", "scripts_modinstalled"?) could be convenient for scripts that are available when the mod is installed, and "scripts_objects" could indicate scripts that relate to the raws, aka the objects folder.
functionally, "scripts_modactive" and "scripts_objects" would be the same, right? They'd both be in the script path when the mod is active for the current world and they'd both not be in the script path when the mod is not active in the current world. Is there any benefit to keeping those two scripts directories separate?
I like the idea of "scripts_modactive" and "scripts_modinstalled", though. tying the names to the mod directories should help make their usage clearer.
@Putnam3145 are there any changes that would need to happen on the DF/Steam workshop side to make it possible for workshop mods to include DFHack scripts?
To summarize the above comments, a workshop mod could include the following directories (containing DFHack lua scripts):
-
scripts_modinstalled/if present, the directory will be included in the DFHack script path as long as the mod is installed, regardless of whether the mod is "active" for the current world -
scripts_modactive/if present, the directory will be added to the DFHack script path when a world is loaded that has this mod active
Does this sound ok? Can modders upload mods that contain lua scripts in these directories right now, or is there a path or file type filter on the steam workshop?
I tested with https://steamcommunity.com/sharedfiles/filedetails/?id=2945575775 and it appears to work just fine.