We digged into testing, and I wrote this simple script which I smashed into my `data.lua`:
Code: Select all
----
--- @param module ModuleID
local function test_require(module)
local ok, err = pcall(require, module)
if (not ok)
then print(("[TRACE]: test-imports: require(%q) -> %s"):format(module, err:gsub("no such file", "\n - ")))
else print(("[ERROR]: test-imports: require(%q) -> OK"):format(module))
end
end
test_require('D:\\git\\factorio\\combinators-bridge\\meta\\info.lua')
test_require('/d/git/factorio/combinators-bridge/meta/info.lua')
test_require('module')
test_require('thismod.module')
test_require('.relative')
test_require('./relative')
test_require('__combinators-bridge__.module')
test_require('__compaktcircuit__.module')
test_require('__inactive__.module')
error("Stop loading")
Note that "D:\\git\\factorio\\combinators-bridge\\meta\\info.lua" is a valid file within the same mod.
Even though the statements 1,2,5,6 should return an "Explicit relative paths are not supported" error message, in practice only #2 did:
Code: Select all
[TRACE]: test-imports: require("thismod.module") -> module thismod.module not found;
- __combinators-bridge__/local/thismod/module.lua
- __combinators-bridge__/thismod/module.lua
- __core__/lualib/thismod/module.lua
[TRACE]: test-imports: require(".relative") -> module .relative not found;
- __combinators-bridge__/local/relative.lua
- __combinators-bridge__/relative.lua
- __core__/lualib/relative.lua
[TRACE]: test-imports: require("./relative") -> module ./relative not found;
- __combinators-bridge__/local/./relative.lua
- __combinators-bridge__/./relative.lua
- __core__/lualib/./relative.lua
[TRACE]: test-imports: require("__combinators-bridge__.module") -> module __combinators-bridge__.module not found;
- __combinators-bridge__/module.lua
[TRACE]: test-imports: require("__compaktcircuit__.module") -> module __compaktcircuit__.module not found;
- __compaktcircuit__/module.lua
[TRACE]: test-imports: require("__inactive__.module") -> Path __inactive__/module.lua does not match any enabled mod.
1.163 Error ModManager.cpp:1625: Failed to load mod "combinators-bridge": __combinators-bridge__/local/test-requires.lua:21: Stop loading