mod.GetModPrefix – return the path prefix for a given mod
prefix = mod.GetModPrefix(mod_name)
Returns a string giving a filesystem path for the given mod. The mod must previously have been registered (i.e., you can't use this with mods that haven't been loaded yet).
This is useful when you want to load files from a different mod. For example, if you want to do something with the "gfx/axe.bmp" file from the base mod (for some reason), the appropriate filename to use would be: mod.GetModPrefix("base") + "gfx/axe.bmp".
Returns a string containing a path prefix. The returned string will always begin and end with a slash (/).
If no mod with the given name exists, then nil is returned.
An error is raised if the first argument is not a string; otherwise, no errors are possible.
All Knights mods load within a "virtual filesystem", so the paths returned will not be real filesystem paths, but rather something like "/base/" or "/spiders/".
Note that when referencing files from your own mod, mod.GetPathPrefix is not necessary – you can just give the path relative to the current Lua script file location. For example, the base mod loads the axe.bmp file using something like kts.Graphic("gfx/axe.bmp", ...) – this works because graphics.lua and gfx are both in the same folder (the root folder of the module in this case), so gfx/axe.bmp is the correct relative path, when starting from graphics.lua.
However, if you want to load data files from another mod (for whatever reason), then you can use mod.GetPathPrefix to find the correct folder location for that other mod.
Note that the folder name won't necessarily be the same as the mod name – so you should always use mod.GetPathPrefix, rather than, say, trying to construct a string like "/" + mod_name + "/" (this will not work in general).