From 4c6a1f063db4102e27937d8c60d0118a1e52e2be Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Tue, 8 Oct 2019 19:56:57 +0200 Subject: [PATCH 1/9] Fix error preventing game from starting instead of showing introduction --- api.lua | 2 +- auto.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api.lua b/api.lua index dc83f50..fde1d5f 100644 --- a/api.lua +++ b/api.lua @@ -32,7 +32,7 @@ local function resolveSurface(surface, default, errorText) end local roundMultiplier = 32 -if fm.autorun.HD then +if fm.autorun and fm.autorun.HD then roundMultiplier = 64 end diff --git a/auto.py b/auto.py index 1ac597d..1f64364 100644 --- a/auto.py +++ b/auto.py @@ -242,7 +242,7 @@ def parseArg(arg): for saveName in savenames: savePath = os.path.join("../../saves", saveName) - if not (os.path.isdir(savePath) or os.path.isfile(savePath + ".zip")): + if not (os.path.isdir(savePath) or os.path.isfile(savePath)): print(f'Cannot find savefile: "{saveName}"') raise ValueError(f'Cannot find savefile: "{saveName}"') From cf229f412262615e198e553b5fa6176ae444d287 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Tue, 8 Oct 2019 19:59:54 +0200 Subject: [PATCH 2/9] Add warning to introduction dialog not to save --- control.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/control.lua b/control.lua index e13e29d..1a9b9aa 100644 --- a/control.lua +++ b/control.lua @@ -263,13 +263,15 @@ script.on_event(defines.events.on_tick, function(event) text = { "Factoriomaps automatic world capture", "Factoriomaps is now finished capturing your game and will close soon.", - "If you believe the script is stuck or you see this screen in error,\nconsider making an issue on the github page: https://git.io/factoriomaps" + "If you believe the script is stuck or you see this screen in error,\nconsider making an issue on the github page: https://git.io/factoriomaps", + "Do not save! This will result in a bricked gamestate." } else text = { "Welcome to FactorioMaps!", "For instructions, check out", - "You can leave the mod disabled while you play.\nThe scripts will automagically enable it when it needs it!" + "You can leave the mod disabled while you play.\nThe scripts will automagically enable it when it needs it!", + "Do not save! This will result in a bricked gamestate." } end @@ -287,6 +289,7 @@ script.on_event(defines.events.on_tick, function(event) end --topLine.add{type = "label", name = "main-end", caption = "."}.style main.add{type = "label", caption = text[3]}.style.single_line = false + main.add{type = "label", caption = text[4]}.style.font = "default-bold" main.style.horizontal_align = "right" From d12721aff5af4afcc73d13e3212e835439799556 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Tue, 8 Oct 2019 20:57:49 +0200 Subject: [PATCH 3/9] added several verbose log statements for easier debugging. --- auto.py | 58 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/auto.py b/auto.py index 1f64364..8830bb0 100644 --- a/auto.py +++ b/auto.py @@ -232,17 +232,19 @@ def parseArg(arg): - args = list(filter(parseArg, args)) - if len(args) > 0: - foldername = args[0] + newArgs = list(filter(parseArg, args)) + if kwargs["verbose"]: + print(args) + if len(newArgs) > 0: + foldername = newArgs[0] else: foldername = os.path.splitext(os.path.basename(max([os.path.join("../../saves", basename) for basename in os.listdir("../../saves") if basename not in { "_autosave1.zip", "_autosave2.zip", "_autosave3.zip" }], key=os.path.getmtime)))[0] print("No save name passed. Using most recent save: %s" % foldername) - savenames = args[1:] or [ foldername ] + savenames = newArgs[1:] or [ foldername ] for saveName in savenames: savePath = os.path.join("../../saves", saveName) - if not (os.path.isdir(savePath) or os.path.isfile(savePath)): + if not (os.path.isdir(savePath) or os.path.isfile(savePath) or os.path.isfile(savePath + ".zip")): print(f'Cannot find savefile: "{saveName}"') raise ValueError(f'Cannot find savefile: "{saveName}"') @@ -463,24 +465,25 @@ def changeModlist(newState): with open("autorun.lua", "w") as f: surfaceString = '{"' + '", "'.join(kwargs["surface"]) + '"}' if len(kwargs["surface"]) > 0 else "nil" - f.write( - f'fm.autorun = {{\n' - f'HD = {str(kwargs["hd"] == True).lower()},\n' - f'day = {str(kwargs["nightonly"] != True).lower()},\n' - f'night = {str(kwargs["dayonly"] != True).lower()},\n' - f'alt_mode = {str(kwargs["no-altmode"] != True).lower()},\n' - f'tags = {str(kwargs["no-tags"] != True).lower()},\n' - f'around_tag_range = {float(kwargs["tag-range"])},\n' - f'around_build_range = {float(kwargs["build-range"])},\n' - f'around_connect_range = {float(kwargs["connect-range"])},\n' - f'connect_types = {{"lamp", "electric-pole", "radar", "straight-rail", "curved-rail", "rail-signal", "rail-chain-signal", "locomotive", "cargo-wagon", "fluid-wagon", "car"}},\n' - f'date = "{datetime.datetime.strptime(kwargs["date"], "%d/%m/%y").strftime("%d/%m/%y")}",\n' - f'surfaces = {surfaceString},\n' - f'name = "{foldername + "/"}",\n' - f'mapInfo = {mapInfoLua},\n' - f'chunkCache = {chunkCache},\n' - f'}}' - ) + autorunString = (f'fm.autorun = {{\n' + f'HD = {str(kwargs["hd"] == True).lower()},\n' + f'day = {str(kwargs["nightonly"] != True).lower()},\n' + f'night = {str(kwargs["dayonly"] != True).lower()},\n' + f'alt_mode = {str(kwargs["no-altmode"] != True).lower()},\n' + f'tags = {str(kwargs["no-tags"] != True).lower()},\n' + f'around_tag_range = {float(kwargs["tag-range"])},\n' + f'around_build_range = {float(kwargs["build-range"])},\n' + f'around_connect_range = {float(kwargs["connect-range"])},\n' + f'connect_types = {{"lamp", "electric-pole", "radar", "straight-rail", "curved-rail", "rail-signal", "rail-chain-signal", "locomotive", "cargo-wagon", "fluid-wagon", "car"}},\n' + f'date = "{datetime.datetime.strptime(kwargs["date"], "%d/%m/%y").strftime("%d/%m/%y")}",\n' + f'surfaces = {surfaceString},\n' + f'name = "{foldername + "/"}",\n' + f'mapInfo = {mapInfoLua},\n' + f'chunkCache = {chunkCache},\n' + f'}}') + f.write(autorunString) + if kwargs["verbose"]: + printErase(autorunString) printErase("building config.ini") @@ -514,8 +517,11 @@ def changeModlist(newState): isSteam = None pidBlacklist = [p.info["pid"] for p in psutil.process_iter(attrs=['pid', 'name']) if p.info['name'] == "factorio.exe"] - popenArgs = (factorioPath, '--load-game', os.path.abspath(os.path.join("../../saves", savename+".zip")), '--disable-audio', '--config', configPath, "--mod-directory", os.path.abspath(kwargs["modpath"]), "--disable-migration-window") - + popenArgs = (factorioPath, '--load-game', os.path.abspath(os.path.join("../../saves", savename)), '--disable-audio', '--config', configPath, "--mod-directory", os.path.abspath(kwargs["modpath"]), "--disable-migration-window") + if kwargs["verbose"]: + printErase(popenArgs) + + condition = mp.Condition() @@ -552,6 +558,8 @@ def changeModlist(newState): with open(datapath, 'r') as f: for line in f: latest.append(line.rstrip("\n")) + if kwargs["verbose"]: + printErase(latest) firstOtherInputs = latest[-1].split(" ") From 26e55d43784340dfb1331d70a7655d813247b5b3 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Tue, 15 Oct 2019 16:38:25 +0200 Subject: [PATCH 4/9] Cleaned up default factorio.exe locations --- auto.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/auto.py b/auto.py index 8830bb0..095634c 100644 --- a/auto.py +++ b/auto.py @@ -248,27 +248,15 @@ def parseArg(arg): print(f'Cannot find savefile: "{saveName}"') raise ValueError(f'Cannot find savefile: "{saveName}"') - possiblePaths = [ - "C:/Program Files/Factorio/bin/x64/factorio.exe", - "D:/Program Files/Factorio/bin/x64/factorio.exe", - "E:/Program Files/Factorio/bin/x64/factorio.exe", - "F:/Program Files/Factorio/bin/x64/factorio.exe", - "G:/Program Files/Factorio/bin/x64/factorio.exe", - "H:/Program Files/Factorio/bin/x64/factorio.exe", - "C:/Games/Factorio/bin/x64/factorio.exe", - "D:/Games/Factorio/bin/x64/factorio.exe", - "E:/Games/Factorio/bin/x64/factorio.exe", - "F:/Games/Factorio/bin/x64/factorio.exe", - "G:/Games/Factorio/bin/x64/factorio.exe", - "H:/Games/Factorio/bin/x64/factorio.exe", + windowsPaths = [ + "Program Files/Factorio/bin/x64/factorio.exe", + "Games/Factorio/bin/x64/factorio.exe", + "Program Files (x86)/Steam/steamapps/common/Factorio/bin/x64/factorio.exe", + "Steam/steamapps/common/Factorio/bin/x64/factorio.exe", + ] + possiblePaths = [driveletter + ":/" + path for driveletter in 'CDEFGHIJKL' for path in windowsPaths] + [ "../../bin/x64/factorio.exe", "../../bin/x64/factorio", - "C:/Program Files (x86)/Steam/steamapps/common/Factorio/bin/x64/factorio.exe", - "D:/Program Files (x86)/Steam/steamapps/common/Factorio/bin/x64/factorio.exe", - "E:/Program Files (x86)/Steam/steamapps/common/Factorio/bin/x64/factorio.exe", - "F:/Program Files (x86)/Steam/steamapps/common/Factorio/bin/x64/factorio.exe", - "G:/Program Files (x86)/Steam/steamapps/common/Factorio/bin/x64/factorio.exe", - "H:/Program Files (x86)/Steam/steamapps/common/Factorio/bin/x64/factorio.exe", ] try: factorioPath = next(x for x in map(os.path.abspath, [kwargs["factorio"]] if kwargs["factorio"] else possiblePaths) if os.path.isfile(x)) From 91054d47a09765775a501b4f1ddec514c2ee8d0c Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Tue, 15 Oct 2019 16:58:39 +0200 Subject: [PATCH 5/9] improved readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 622eaaa..ede81ae 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,9 @@ Mod portal link: https://mods.factorio.com/mod/L0laapk3_FactorioMaps # How to Install **Note that this program now only runs on 64 bit python version 3.6 or higher.** 1. Download FactorioMaps to `%appdata%\mods\`, either from the [mod portal](https://mods.factorio.com/mod/L0laapk3_FactorioMaps) (The mod does not need to be enabled to work) and then unzipping it, or from [the github releases page](https://github.com/L0laapk3/FactorioMaps/releases). -1. Install the latest version of [**64 bit** python 3.7](https://www.python.org/downloads/). (Do not install python 2.) -1. Recommended: [Add python to your environment variables](https://stackoverflow.com/a/4855685/3185280). -1. Install pip: Download the latest [get-pip.py](https://bootstrap.pypa.io/get-pip.py), and run it (`python get-pip.py` in the command line). -1. Install the following pip packages: `pip install -r packages.txt`. +1. Install the latest version of [**64 bit** python 3.7](https://www.python.org/downloads/). (Do not install python 2.) +Make sure to do a select the "add python to PATH" and "install pip" options. +1. Inside the factoriomaps folder, install the required pip packages: `python -m pip install -r packages.txt`. # How to Use 1. Make sure you close factorio before starting the process. @@ -24,7 +23,8 @@ Mod portal link: https://mods.factorio.com/mod/L0laapk3_FactorioMaps * `python auto.py outfolder savename` Generate a snapshot of *savename* and store it to folder *outfolder*. * `python auto.py outfolder savename1 savename2 savename3` Generate timeline snapshots of *savename1*, *savename2*, *savename3* in that order, and store it to folder *outfolder*. * `python auto.py --factorio=PATH` Same as `python auto.py`, but will use `factorio.exe` from *PATH* instead of attempting to find it in common locations. - * `python auto.py --verbosegame` Display *all* game logs. + * `python auto.py --verbose` Displays factoriomaps related logs. + * `python auto.py --verbosegame` Displays *all* game logs. * `python auto.py --basepath=PATH` Same as `python auto.py`, but will output to *PATH* instead of `script-output\FactorioMaps`. Not recommended to use. 1. An `index.html` will be created in `%appdata%\Factorio\script-output\FactorioMaps\mapName`. Enjoy! From 4e10a6f43a91d6c488e01c9d3e69e49f6a5dc77e Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Tue, 15 Oct 2019 16:59:42 +0200 Subject: [PATCH 6/9] removed dependency on package that isnt being updated --- packages.txt | 1 - zoom.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages.txt b/packages.txt index 99c6341..4eea34e 100644 --- a/packages.txt +++ b/packages.txt @@ -1,5 +1,4 @@ PyTurboJPEG>=1.1.5 -opencv_python>=4.1.0.25 psutil>=5.4.8 numpy>=1.16.4 Pillow>=6.1.0 diff --git a/zoom.py b/zoom.py index 5e09b3b..35ab52c 100644 --- a/zoom.py +++ b/zoom.py @@ -5,7 +5,7 @@ import subprocess import sys import time -import cv2, numpy +import numpy from turbojpeg import TurboJPEG from shutil import get_terminal_size as tsize from sys import platform as _platform @@ -33,7 +33,7 @@ def printErase(arg): try: tsiz = tsize()[0] print("\r{}{}\n".format(arg, " " * (tsiz*math.ceil(len(arg)/tsiz)-len(arg) - 1)), end="", flush=True) - except e: + except: #raise pass From b618ed004b1824eec7f36966b9b12fcb379e487e Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Tue, 15 Oct 2019 17:00:24 +0200 Subject: [PATCH 7/9] improved readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ede81ae..b407435 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Mod portal link: https://mods.factorio.com/mod/L0laapk3_FactorioMaps # How to Install **Note that this program now only runs on 64 bit python version 3.6 or higher.** 1. Download FactorioMaps to `%appdata%\mods\`, either from the [mod portal](https://mods.factorio.com/mod/L0laapk3_FactorioMaps) (The mod does not need to be enabled to work) and then unzipping it, or from [the github releases page](https://github.com/L0laapk3/FactorioMaps/releases). -1. Install the latest version of [**64 bit** python 3.7](https://www.python.org/downloads/). (Do not install python 2.) +1. Install the latest version of [**64 bit** python 3](https://www.python.org/downloads/). (Do *not* install python 2.) Make sure to do a select the "add python to PATH" and "install pip" options. 1. Inside the factoriomaps folder, install the required pip packages: `python -m pip install -r packages.txt`. From a18892b3711efd6d6b42459601f76d05bd159b41 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Tue, 15 Oct 2019 17:03:33 +0200 Subject: [PATCH 8/9] Changed download link in update available screen --- auto.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/auto.py b/auto.py index 095634c..0fd67ec 100644 --- a/auto.py +++ b/auto.py @@ -325,9 +325,7 @@ def parseArg(arg): print(line) print("") print("") - print(" Download: https://mods.factorio.com/mod/L0laapk3_FactorioMaps") - print(" OR") - print(" https://github.com/L0laapk3/FactorioMaps") + print(" Download: https://git.io/factoriomaps") if majorUpdate: print("") print("You can dismiss this by using --noupdate (not recommended)") From 5ba84bde2031baca747eca22d8f7b061e62072c1 Mon Sep 17 00:00:00 2001 From: L0laapk3 Date: Tue, 15 Oct 2019 17:03:38 +0200 Subject: [PATCH 9/9] bump version number --- info.json | 2 +- updates.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/info.json b/info.json index 067db7a..c05fe4f 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "L0laapk3_FactorioMaps", - "version": "3.5.0", + "version": "3.5.1", "title": "FactorioMaps", "author": "L0laapk3", "contact": "https://github.com/L0laapk3/", diff --git a/updates.json b/updates.json index 0e9a85e..ac6447b 100644 --- a/updates.json +++ b/updates.json @@ -25,5 +25,6 @@ "3.3.1": "Fixed a bug where some parts of the map could be missing if multiple factions were used", "3.3.2": "Many bugfixes.", "3.4.0": ["Separated map tags to surface and snapshot level", "Thumbnail generation of the map"], - "3.5.0": ["!Added API for integration with i.a. Factorissimo", "Better dependency management", "Several bugfixes"] + "3.5.0": ["!Added API for integration with i.a. Factorissimo", "Better dependency management", "Several bugfixes"], + "3.5.1": "Removed dependency on package that isnt being updated anymore." } \ No newline at end of file