Unable to find file due to double underscores in mod paths.

Place to get help with not working mods / modding interface.
Post Reply
SandSnip3r
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Apr 28, 2017 1:15 am
Contact:

Unable to find file due to double underscores in mod paths.

Post by SandSnip3r »

I am trying to find a nice calculator to use with the space exploration mod. I've used KirkMcDonald's calculator before and I'm pretty comfortable with it. He provides some tools that make it easy enough to dump the Factorio game and mod data and run the calculator using this data.

However, the issue that I'm running into is that, for example, in the alien_biomes mod, data.lua has the line:

Code: Select all

require("__alien-biomes__/collision-mask-util-extended/data/collision-mask-util-extended")
The problem is that it cannot find this double underscored path. I assume his data dump tool is loading a lot of the lua code of the base game and all mods.

Here's a longer snippet of the error:

Code: Select all

[string "alien-biomes/data.lua"]:5: module '__alien-biomes__/collision-mask-util-extended/data/collision-mask-util-extended' not found:Not found: __alien-biomes__/collision-mask-util-extended/data/collision-mask-util-extended in /.../AppData/Roaming/Factorio/mods/alien-biomes_0.6.4.zip
I don't think that my issue is directly related to anything KirkMcDonald's has done, but it's just something I'm not understanding about how lua follows paths. I've looked around and I've seen that this double-underscore method is the naming convention that Factorio uses for mods (even __base__).

Trific
Fast Inserter
Fast Inserter
Posts: 147
Joined: Thu Dec 31, 2020 7:57 pm
Contact:

Re: Unable to find file due to double underscores in mod paths.

Post by Trific »

Yes, it's a special convention.

Code: Select all

__alien-biomes__
means "the root of the mod named alien-biomes". It's magic that makes it work whether it is in a zip file or not, etc.

SandSnip3r
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Apr 28, 2017 1:15 am
Contact:

Re: Unable to find file due to double underscores in mod paths.

Post by SandSnip3r »

Then how does this `require` function in the mod's data.lua file work (the line of lua souce in my original post)? It looks like a native part of lua? Has the Factorio source overridden how it behaves? Maybe I need to modify this factoriodump tool to behave similarly?

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2633
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Unable to find file due to double underscores in mod paths.

Post by steinio »

Just remove the mod during data collection.
It doesn't add relevant data for the calculator.

You can add it again afterwards.
Image

Transport Belt Repair Man

View unread Posts

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Unable to find file due to double underscores in mod paths.

Post by DaveMcW »

SandSnip3r wrote:
Mon Feb 01, 2021 9:11 pm
Has the Factorio source overridden how it behaves? Maybe I need to modify this factoriodump tool to behave similarly?
Yes, the double underscore require is a Factorio extension.

SandSnip3r
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Apr 28, 2017 1:15 am
Contact:

Re: Unable to find file due to double underscores in mod paths.

Post by SandSnip3r »

steinio wrote:
Mon Feb 01, 2021 10:23 pm
Just remove the mod during data collection.
It doesn't add relevant data for the calculator.

You can add it again afterwards.
It's not just an issue with the alien biomes mod (which is required for space exploration). This problem initially occurred for __base__ too, but that was easy to solve by just duplicating the directory.

I cant just "remove the mod" because the whole point of this endeavor is to create a calculator that works with my existing mods.

Bilka
Factorio Staff
Factorio Staff
Posts: 3130
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Unable to find file due to double underscores in mod paths.

Post by Bilka »

SandSnip3r wrote:
Tue Feb 02, 2021 6:09 pm
the whole point of this endeavor is to create a calculator that works with my existing mods.
You could use a different data dumper tool. I personally maintain https://github.com/demodude4u/Java-Fact ... ta-Wrapper which recently got the special require support and really wasn't all that hard to add, only took like two days. Though due the lack of documentation, it might not be the best tool to recommend :p

viewtopic.php?p=524263#p524263 has a general list of data dumper tools, with no recommendation attached from my side, just a (incomplete) collection to link to people like you.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

SandSnip3r
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Apr 28, 2017 1:15 am
Contact:

Re: Unable to find file due to double underscores in mod paths.

Post by SandSnip3r »

Bilka wrote:
Tue Feb 02, 2021 6:20 pm
SandSnip3r wrote:
Tue Feb 02, 2021 6:09 pm
the whole point of this endeavor is to create a calculator that works with my existing mods.
You could use a different data dumper tool. I personally maintain https://github.com/demodude4u/Java-Fact ... ta-Wrapper which recently got the special require support and really wasn't all that hard to add, only took like two days. Though due the lack of documentation, it might not be the best tool to recommend :p

viewtopic.php?p=524263#p524263 has a general list of data dumper tools, with no recommendation attached from my side, just a (incomplete) collection to link to people like you.
Thanks for sharing Bilka. I guess if I were to use one of these other data dumping tools, I'd have to massage the data bit to feed it into this calculator. Maybe it would be a similar amount of work to update this existing data dumping tool that I'm trying to use to have the "special require support". Could you help me to understand what's involved in a change like this? I don't expect you to tell me how to exactly do it for the tool I'm working with, but maybe just a general overview of how things used to work and how they work now?

Bilka
Factorio Staff
Factorio Staff
Posts: 3130
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Unable to find file due to double underscores in mod paths.

Post by Bilka »

SandSnip3r wrote:
Wed Feb 03, 2021 4:02 pm
Thanks for sharing Bilka. I guess if I were to use one of these other data dumping tools, I'd have to massage the data bit to feed it into this calculator. Maybe it would be a similar amount of work to update this existing data dumping tool that I'm trying to use to have the "special require support". Could you help me to understand what's involved in a change like this? I don't expect you to tell me how to exactly do it for the tool I'm working with, but maybe just a general overview of how things used to work and how they work now?
Factorio just takes the path in require, tries to transform __mod-name__ to a proper path and then loads that file. https://github.com/demodude4u/Java-Fact ... er/pull/35 does the same, but inside something that seems to be the LuaJ equivalent of a function in package.searchers (https://www.lua.org/manual/5.2/manual.html#pdf-require). https://github.com/KirkMcDonald/factori ... ad.go#L122 is a function in package.searchers. But I'd guess that you'd have to make your own somewhere in https://github.com/KirkMcDonald/Factori ... loader.lua.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

Post Reply

Return to “Modding help”