Skip to content

Commit bd08875

Browse files
committed
Merge branch 'dev'
2 parents 174501d + b219e7e commit bd08875

10 files changed

+40
-23
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
![image](https://user-images.githubusercontent.com/6313423/46447780-0d723880-c784-11e8-8e6f-2b35d24f25b9.png)
33
This [Factorio](http://www.factorio.com/) mod turns your factory into a timeline! You can view the map locally or upload it to a web server.
44

5-
Live demo: https://factoriomaps.com/beta/user/L0laapk3/megabase/index.html
6-
75
Mod portal link: https://mods.factorio.com/mod/L0laapk3_FactorioMaps
86

97
# How to Install

auto.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
from pathlib import Path
1212

1313
try:
14-
with Path(__file__, "..", "packages.txt").open("r", encoding="utf-8") as f:
14+
with Path(__file__, "..", "packages.txt").resolve().open("r", encoding="utf-8") as f:
1515
pkg_resources.require(f.read().splitlines())
1616
except (DistributionNotFound, VersionConflict) as ex:
1717
traceback.print_exc()
1818
print("\nDependencies not met. Run `pip install -r packages.txt` to install missing dependencies.")
1919
sys.exit(1)
2020

21+
import glob
2122
import argparse
2223
import configparser
2324
import datetime
@@ -169,7 +170,7 @@ def checkUpdate(reverseUpdateTest:bool = False):
169170
try:
170171
print("checking for updates")
171172
latestUpdates = json.loads(urllib.request.urlopen('https://cdn.jsdelivr.net/gh/L0laapk3/FactorioMaps@latest/updates.json', timeout=30).read())
172-
with Path(__file__, "..", "updates.json").open("r", encoding="utf-8") as f:
173+
with Path(__file__, "..", "updates.json").resolve().open("r", encoding="utf-8") as f:
173174
currentUpdates = json.load(f)
174175
if reverseUpdateTest:
175176
latestUpdates, currentUpdates = currentUpdates, latestUpdates
@@ -294,7 +295,7 @@ def buildAutorun(args: Namespace, workFolder: Path, outFolder: Path, isFirstSnap
294295
def lowerBool(value: bool):
295296
return str(value).lower()
296297

297-
with open("autorun.lua", "w", encoding="utf-8") as f:
298+
with Path(__file__, "..", "autorun.lua").resolve().open("w", encoding="utf-8") as f:
298299
surfaceString = '{"' + '", "'.join(args.surface) + '"}' if args.surface else "nil"
299300
autorunString = \
300301
f'''fm.autorun = {{
@@ -335,6 +336,8 @@ def buildConfig(args: Namespace, tmpDir, basepath):
335336
config["path"] = {}
336337
config["path"]["write-data"] = tmpDir
337338

339+
config["path"]["script-output"] = str(basepath)
340+
338341
if "graphics" not in config:
339342
config["graphics"] = {}
340343
config["graphics"]["screenshots-threads-count"] = str(args.screenshotthreads if args.screenshotthreads else args.maxthreads)
@@ -344,9 +347,6 @@ def buildConfig(args: Namespace, tmpDir, basepath):
344347
configFile.writelines(("; version=3\n", ))
345348
config.write(configFile, space_around_delimiters=False)
346349

347-
# TODO: change this when https://forums.factorio.com/viewtopic.php?f=28&t=81221 is implemented
348-
linkDir(Path(tmpDir, "script-output"), basepath)
349-
350350
copy(Path(userFolder, 'player-data.json'), tmpDir)
351351

352352
return configPath
@@ -427,8 +427,9 @@ def kill(pid, onlyStall=False):
427427

428428
saveGames = OrderedSet()
429429
for saveName in saveNames:
430-
globResults = list(saves.glob(saveName))
431-
globResults += list(saves.glob(f"{saveName}.zip"))
430+
saveNameEscaped = glob.escape(saveName).replace("[*]", "*")
431+
globResults = list(saves.glob(saveNameEscaped))
432+
globResults += list(saves.glob(f"{saveNameEscaped}.zip"))
432433

433434
if not globResults:
434435
print(f'Cannot find savefile: "{saveName}"')
@@ -601,7 +602,7 @@ def kill(pid, onlyStall=False):
601602
time.sleep(0.4)
602603

603604
# empty autorun.lua
604-
open("autorun.lua", 'w', encoding="utf-8").close()
605+
Path(__file__, "..", "autorun.lua").resolve().open('w', encoding="utf-8").close()
605606

606607
latest = []
607608
with datapath.open('r', encoding="utf-8") as f:
@@ -701,9 +702,10 @@ def refZoom():
701702
for surfaceName, surfaceStuff in mapStuff["surfaces"].items():
702703
if "chunks" in surfaceStuff:
703704
data["maps"][int(mapIndex)]["surfaces"][surfaceName]["chunks"] = surfaceStuff["chunks"]
704-
for linkIndex, link in enumerate(surfaceStuff["links"]):
705-
data["maps"][int(mapIndex)]["surfaces"][surfaceName]["links"][linkIndex]["path"] = link["path"]
706-
data["maps"][int(mapIndex)]["surfaces"][surfaceName]["links"][linkIndex]["zoom"]["min"] = link["zoom"]["min"]
705+
if "links" in surfaceStuff:
706+
for linkIndex, link in enumerate(surfaceStuff["links"]):
707+
data["maps"][int(mapIndex)]["surfaces"][surfaceName]["links"][linkIndex]["path"] = link["path"]
708+
data["maps"][int(mapIndex)]["surfaces"][surfaceName]["links"][linkIndex]["zoom"]["min"] = link["zoom"]["min"]
707709
destf.seek(0)
708710
json.dump(data, destf)
709711
destf.truncate()

control.lua

+8-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ script.on_event(defines.events.on_tick, function(event)
255255

256256
game.tick_paused = true
257257
game.ticks_to_run = 0
258-
player.character.active = false
258+
if player.character then
259+
player.character.active = false
260+
end
259261

260262
local main = player.gui.center.add{type = "frame", caption = text[1], direction = "vertical"}
261263
local topLine = main.add{type = "flow", direction = "horizontal"}
@@ -286,3 +288,8 @@ script.on_event(defines.events.on_tick, function(event)
286288

287289
end
288290
end)
291+
292+
function unpause()
293+
game.tick_paused = false
294+
end
295+
script.on_init(unpause)

crop.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def crop(outFolder, timestamp, surface, daytime, basePath=None, args: Namespace
4242

4343
subname = Path(timestamp, surface, daytime)
4444
toppath = Path(
45-
basePath if basePath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps"),
45+
basePath if basePath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps").resolve(),
4646
outFolder,
4747
)
4848

data.lua

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
_, _, mainVersion, majorVersion, minorVersion = string.find(mods["base"], "(%d+)%.(%d+)%.(%d+)")
2+
if tonumber(mainVersion) <= 0 and tonumber(majorVersion) <= 18 and tonumber(minorVersion) < 29 then
3+
error("\nThis version of factorioMaps requires factorio 0.18.29 or higher!")
4+
end

info.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "L0laapk3_FactorioMaps",
3-
"version": "4.0.1",
3+
"version": "4.1.0",
44
"title": "FactorioMaps",
55
"author": "L0laapk3",
66
"contact": "https://github.com/L0laapk3/",

ref.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def ref(
107107

108108
psutil.Process(os.getpid()).nice(psutil.BELOW_NORMAL_PRIORITY_CLASS if os.name == 'nt' else 10)
109109

110-
workFolder = basepath if basepath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps")
110+
workFolder = basepath if basepath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps").resolve()
111111
topPath = Path(workFolder, outFolder)
112112
dataPath = Path(topPath, "mapInfo.json")
113113
maxthreads = args.refthreads if args.refthreads else args.maxthreads

updateLib.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
def update(Force=True):
2626

27-
targetPath = Path(__file__, "..", "web", "lib")
27+
targetPath = Path(__file__, "..", "web", "lib").resolve()
2828

2929
if not Force:
3030
try:

updates.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,11 @@
6161
"Day and night snapshots are now completely identical instead of 1 tick apart",
6262
"Added option to set the default snapshot when the page loads"
6363
],
64-
"4.0.1": "!Bugfix with default snapshot index"
64+
"4.0.1": "!Bugfix with default snapshot index",
65+
"4.1.0": [
66+
"Replace symlinks with the new script-output config option, restore linux compatibility",
67+
"Fix for editor/god mode maps",
68+
"Fix for when the CWD is different than the script directory",
69+
"Bugfixes :)"
70+
]
6571
}

zoom.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ def printErase(arg):
4141

4242
# note that these are all 64 bit libraries since factorio doesnt support 32 bit.
4343
if os.name == "nt":
44-
jpeg = TurboJPEG(Path(__file__, "..", "mozjpeg/turbojpeg.dll").as_posix())
44+
jpeg = TurboJPEG(Path(__file__, "..", "mozjpeg/turbojpeg.dll").resolve().as_posix())
4545
# elif _platform == "darwin": # I'm not actually sure if mac can run linux libraries or not.
4646
# jpeg = TurboJPEG("mozjpeg/libturbojpeg.dylib") # If anyone on mac has problems with the line below please make an issue :)
4747
else:
48-
jpeg = TurboJPEG(Path(__file__, "..", "mozjpeg/libturbojpeg.so").as_posix())
48+
jpeg = TurboJPEG(Path(__file__, "..", "mozjpeg/libturbojpeg.so").resolve().as_posix())
4949

5050

5151
def saveCompress(img, path: Path):
@@ -270,7 +270,7 @@ def zoom(
270270

271271
psutil.Process(os.getpid()).nice(psutil.BELOW_NORMAL_PRIORITY_CLASS if os.name == "nt" else 10)
272272

273-
workFolder = basepath if basepath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps")
273+
workFolder = basepath if basepath else Path(__file__, "..", "..", "..", "script-output", "FactorioMaps").resolve()
274274

275275
topPath = Path(workFolder, outFolder)
276276
dataPath = Path(topPath, "mapInfo.json")

0 commit comments

Comments
 (0)