Page 1 of 1

[0.17.7] Requiring lua scripts from other mods: incorrect path to file

Posted: Thu Mar 07, 2019 12:20 pm
by eduran
I am trying to require a script file from another mod in my mod during the data stage. The target file sits in a subfolder of this mod and itself requires further files. While the original mod loads fine, requiring the mod's script file from my mod messes up all further requires inside that file.

Minimal working example (ready-to-use version attached):

mod_A/data.lua:

Code: Select all

require("__mod_B__.subfolder.some_script")
mod_B/subfolder/some_script:

Code: Select all

require("subfolder.helper_script")
helper_script.lua also sits inside mod_B/subfolder.

This situation leads to the following error (complete log attached):

Failed to load mods: __mod_A__/data.lua:1: __mod_B__/subfolder/some_script.lua:1: module subfolder.helper_script not found;
no such file __mod_B__/subfolder/subfolder/helper_script.lua
no such file __mod_A__/subfolder/helper_script.lua
no such file D:/Programme/Steam/steamapps/common/Factorio/data/core/lualib/subfolder/helper_script.lua

Re: [0.17.7] Requiring lua scripts from other mods: incorrect path to file

Posted: Wed May 15, 2019 5:41 am
by Rseding91
Thanks for the report. I don't have a solution to this that wouldn't break virtually every mod that exists.

If you want cross-mod-require to work fully correctly you need every single "require" to use the full mod prefix and path to the file and never use relative paths.

Re: [0.17.7] Requiring lua scripts from other mods: incorrect path to file

Posted: Tue Sep 07, 2021 12:27 pm
by eradicator
Rseding91 wrote: Wed May 15, 2019 5:41 am If you want cross-mod-require to work fully correctly you need every single "require" to use the full mod prefix and path to the file and never use relative paths.
It would be nice if the base game would lead by example :mrgreen: as it's currently not easy to cross-require base game files.