A NWN-like resman implementation.
Allows stacking resources origins with ChainMap semantics with similar lookup behaviour to the NWN engine.
The provided default implementation will correctly look up user-configured aliases. If you do not want this behaviour, you can create your own ResMan/ChainMap by combining your own resource containers; or you can override the env var NWN_ROOT/NWN_HOME to point to a custom installation/user directory.
Example
>>> from nwn.erf import Reader as ErfReader ... from nwn.res import ResDict ... from nwn.resdir import ResDir ... from nwn.resman import create as create_resman ... ... module_erf = ErfReader("mymodule.erf") ... inmem = ResDict() ... rm = create_resman(inmem, ResDir("local_dir"), module_erf) ... ... ifo = rm["module.ifo"] # from mymodule.erf ... nss = rm["nwscript.nss"] # from retail keyfile ... rm["temp.txt"] = b"SomeData" # writes to inmem dict
| Class | |
A resource manager that chains multiple resource mappings together. |
| Function | create |
Create a default resman instance containing all base and user game data, in addition to any additional resource maps provided. Uses the environment to locate NWN installation and user directories. |
Create a default resman instance containing all base and user game data, in addition to any additional resource maps provided. Uses the environment to locate NWN installation and user directories.
Hint: If you want to create a resman that can also store data, prefix your maps chain with a ResDict() instance (for in-memory storage or a ResDir(..., writable=True) instance pointing to a writable directory).
| Parameters | |
*maps:Container | Additional resource maps to include in the resman, in order of precedence (first has highest precedence). |
includebool | Whether to include the user directory aliases. |
| Returns | |
ResMan | A ResMan containing all provided resource maps, plus the base game resource keys. |
| Raises | |
FileNotFoundError | If any of the required directories cannot be found. |