[Rseding] [0.17.79] Script mismatch when migration contains require

This subforum contains all the issues which we already resolved.
asdff45
Long Handed Inserter
Long Handed Inserter
Posts: 65
Joined: Sun Aug 07, 2016 1:23 pm
Contact:

[Rseding] [0.17.79] Script mismatch when migration contains require

Post by asdff45 »

As the title says, i noticed, that when adding a mod to a save, a `require` in migration scripts cause a multiplayer script-mismatch, when connecting to the server.

Step by Step:
  • download client and server
  • create a new save without any mods
  • add the mod attached to this bugreport
  • start the server and notice, that the migration script is applied and has a script mismatch:

    Code: Select all

    0.757 Applying migration: Script Mismatch: 2020-01-03_script-mismatch_1.0.0.lua
    test
  • start the client with the attached mod active and connect to the server. Then a script mismatch error occurs.

    Code: Select all

      20.048 Error ClientMultiplayerManager.cpp:101: MultiplayerManager failed: "" + multiplayer.script-mismatch + "
    " + "
    
The attached mod is a 5 line sized mod, just to test this error.
My original mod and my original post about this error: viewtopic.php?f=25&t=79319&p=472204

Edit: I just noticed, that the error also occurs on the server, so, the client must not connect to the server
Attachments
factorio-current.log
Server-Log with migration, that causes script-mismatch error
(5.56 KiB) Downloaded 125 times
factorio-current.log
Client-Log with the script-mismatch error
(6.73 KiB) Downloaded 135 times
script-mismatch_1.0.0.zip
broken Mod
(1.84 KiB) Downloaded 132 times

PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: [0.17.79] Script mismatch when migration contains require

Post by PyroFire »

require usually branches from the file that ran the function.

Try doing require("../test")

asdff45
Long Handed Inserter
Long Handed Inserter
Posts: 65
Joined: Sun Aug 07, 2016 1:23 pm
Contact:

Re: [0.17.79] Script mismatch when migration contains require

Post by asdff45 »

https://lua-api.factorio.com/latest/Libraries.html
require()

Due to the changes to package, the functionality of require() changes. When using absolute paths, the path starts at the mod root, additionally .. is disabled as a path variable. This means that it is not possible to load arbitrary files from outside the mod directory. However, Factorio provides two ways to load files from other mods:

The lualib directory of the core mod is included in the paths to be checked for files, so it is possible to require files directly from there, such as the util file: require("util").
Furthermore, it is possible to require files from other mods by using require("__mod-name__.file").

require() can not be used in the console, in event listeners or during a remote.call(). The function expects any file to end with the .lua extension.
And also the `test` output is also shown in the log, so the file gets required and the function executed

Rseding91
Factorio Staff
Factorio Staff
Posts: 14166
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Rseding] [0.17.79] Script mismatch when migration contains require

Post by Rseding91 »

Thanks for the report. It's now fixed for the next release.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Resolved Problems and Bugs”