Danacus/node-factorio-api

getModsFromSaves() returns jargon with larger mod sets

Closed this issue · 11 comments

https://pastebin.com/SHx2JJpc

The code used:

factorioAPI.getModsFromSaves().then(list => {
    console.log("Mods used in save:");
    console.log(JSON.stringify(list))
    console.log(asTable(list[0].mods))
});

I'm going to be very honest with you. The code for getting mods from a save file isn't actually mine. I found it somewhere and it worked (I forget where I found it), but it might be outdated and incompatible with 0.15. So I have no idea why it's not working and how to fix it. I'll look for a solution when I have got the time to do so.

JARG had a lot at the error and said it looked like it was unzipped and then just returned the data as a string, which would explain why definitions from data.lua has become muddled in there.

Might help you debug.

Fixed in #3

The number of bytes between mods changed in Factorio version 0.15 from 4 to 8. I made a pull request correcting this and also corrected a little offset bug when reading the name, so it should no longer be needed to trim the name or remove non-ASCII characters.

BTW you might have found the original the same place i did https://forums.factorio.com/viewtopic.php?f=69&t=35644

I merged your pull request, thanks a lot! I did indeed find the code from AlyxDeLunar. I didn't test anything or make any changes since 0.15 released, so I didn't know that it didn't work anymore.

Sounds like we need unit tests, but good job on fixing this one 👍

I did initially make unit tests, but they don't work very well, because of timeouts when it takes too long to download a mod.

Thanks! That's really useful.

Using the latest package version on NPM (0.1.28) I still get the same error as when I created this issue. This is on a map generated in 0.15.37.

Should this issue be reopened?

The last pull request was merged 1 month ago, but the last time I updated the package was 2 months ago. I might have forgotten to update the package.