Base of "required" files in different environments
Posted: Fri May 01, 2020 9:16 pm
I've got a bug report against Bio Industries for a crash when the player wants to start a mini tutorial from the main game. I caught this in my log file:
I use a file "__Bio_Industries__/common.lua" for some functions I want to access in the data stage, during migration, and from control.lua. This is the offending line from __Bio_Industries__/migrations/Bio_Industries_0.17.02.lua:
This works as expected most of the time: require('common') will look for a file relative to the mod's root dir, and as you can see in the log snippet, the file is parsed correctly when a saved game is loaded. However, this breaks once I try to start a tutorial. It seems to look for the required file only in the current directory and in a location relative to the core game's root dir. Is that behavior intended?
For me, this is bad news because I use such "common.lua" files in several mods. The obvious way to solve this problem would be to create a link from __Bio_Industries__/migrations/common.lua to __Bio_Industries__/common.lua . However, when i zip the folder, the link is replaced with a duplicate of the file. This takes up more space -- and it may cause problems in the future if I unpack the zip file and make changes in only one copy of that file. So is there any better solution?
Another problem I noticed while looking over the log again: Is there a way to enforce an order for the execution of migration files? It doesn't make sense that the migration files for 0.18 are run before the files for 0.17, and I imagine it actually could cause problems.
Code: Select all
41.098 Loading map /home/pc/GOG_Games/Factorio/test/saves/Maps_test.zip: 1895648 bytes.
41.109 Loading level.dat: 2138610 bytes.
41.114 Info Scenario.cpp:187: Map version 0.18.22-1
41.117 Info PrototypeMigrationList.cpp:61: Activating migration Bio_Industries/Bio_Industries_0.17.19.json
41.117 Info PrototypeMigrationList.cpp:61: Activating migration Bio_Industries/Bio_Industries_0.18.01.json
41.202 Loading script.dat: 365 bytes.
41.204 Checksum for script /home/pc/GOG_Games/Factorio/test/temp/currently-playing/control.lua: 2466797803
41.220 Checksum for script __Bio_Industries__/control.lua: 1707007530
41.223 Applying migration: Bio Industries: Bio_Industries_0.17.02.lua
[…]
112.496 Supending game state
112.496 Entering tutorial: [base]stack-transfers
112.504 Loading level.dat: 1185316 bytes.
112.504 Info Scenario.cpp:187: Map version 0.18.1-0
112.506 Info PrototypeMigrationList.cpp:61: Activating migration Bio_Industries/Bio_Industries_0.17.19.json
112.506 Info PrototypeMigrationList.cpp:61: Activating migration Bio_Industries/Bio_Industries_0.18.01.json
112.568 Checksum for script /home/pc/GOG_Games/Factorio/test/temp/currently-playing-tutorial/control.lua: 3313316706
112.569 Applying migration: Base Mod: 2020-01-27_Factorio_0.18.02.lua
112.570 Applying migration: Base Mod: 2020-03-18_Factorio_0.18.14.lua
112.572 Applying migration: Bio Industries: Bio_Industries_0.17.02.lua
112.635 Error AppManager.cpp:687: Failed to load tutorial: Error while applying migration: Bio Industries: Bio_Industries_0.17.02.lua
__Bio_Industries__/migrations/Bio_Industries_0.17.02.lua:1: module common not found; no such file __Bio_Industries__/migrations/common.lua no such file __core__/lualib/common.lua
stack traceback:
[C]: in function 'require'
__Bio_Industries__/migrations/Bio_Industries_0.17.02.lua:1: in main chunk
Code: Select all
local BioInd = require('common')
For me, this is bad news because I use such "common.lua" files in several mods. The obvious way to solve this problem would be to create a link from __Bio_Industries__/migrations/common.lua to __Bio_Industries__/common.lua . However, when i zip the folder, the link is replaced with a duplicate of the file. This takes up more space -- and it may cause problems in the future if I unpack the zip file and make changes in only one copy of that file. So is there any better solution?
Another problem I noticed while looking over the log again: Is there a way to enforce an order for the execution of migration files? It doesn't make sense that the migration files for 0.18 are run before the files for 0.17, and I imagine it actually could cause problems.