When a file is imported using "__modname__.path.to.file", the behaviour of "require" within that file changes (vs a "normal" require).
Based on my observations:
If the file is in the root of the mod directory, relative imports do not work at all.
If the file is in a folder, relative imports are searched for in the folder rather than the root of the mod directory. E.g. inside "mod1/folder/foo.lua", a require("bar") tries to look for "__mod1__/folder/bar.lua". whereas normally it would search for "__mod1__/bar.lua"
This seems like very weird behaviour.
If this is intentional, this could be added to documentation
If this is not intentional... I guess this is a bug report.
inconsistent `require` behavior when files imported by other mods
-
- Inserter
- Posts: 31
- Joined: Fri Jun 11, 2021 5:20 pm
- Contact:
Re: inconsistent `require` behavior when files imported by other mods
See: 67032
If you want to get ahold of me I'm almost always on Discord.