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

We are aware of them, but they have low priority. We have more important things to do. They go here in order not to take space in the main bug thread list.
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

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

Post 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
Attachments
factorio-current.log
(4.19 KiB) Downloaded 119 times
mod_B_0.0.1.zip
(1.18 KiB) Downloaded 124 times
mod_A_0.0.1.zip
(638 Bytes) Downloaded 128 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 14674
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Minor issues”