Page 1 of 1
Unable to find file due to double underscores in mod paths.
Posted: Mon Feb 01, 2021 6:33 pm
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__).
Re: Unable to find file due to double underscores in mod paths.
Posted: Mon Feb 01, 2021 8:34 pm
by Trific
Yes, it's a special convention.
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.
Re: Unable to find file due to double underscores in mod paths.
Posted: Mon Feb 01, 2021 9:11 pm
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?
Re: Unable to find file due to double underscores in mod paths.
Posted: Mon Feb 01, 2021 10:23 pm
by steinio
Just remove the mod during data collection.
It doesn't add relevant data for the calculator.
You can add it again afterwards.
Re: Unable to find file due to double underscores in mod paths.
Posted: Tue Feb 02, 2021 2:41 am
by DaveMcW
SandSnip3r wrote: Mon Feb 01, 2021 9:11 pmHas 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.
Re: Unable to find file due to double underscores in mod paths.
Posted: Tue Feb 02, 2021 6:09 pm
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.
Re: Unable to find file due to double underscores in mod paths.
Posted: Tue Feb 02, 2021 6:20 pm
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.
Re: Unable to find file due to double underscores in mod paths.
Posted: Wed Feb 03, 2021 4:02 pm
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?
Re: Unable to find file due to double underscores in mod paths.
Posted: Wed Feb 03, 2021 5:51 pm
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.