Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] option to override "savename" #60

Open
Kariton opened this issue Dec 1, 2024 · 1 comment
Open

[FR] option to override "savename" #60

Kariton opened this issue Dec 1, 2024 · 1 comment

Comments

@Kariton
Copy link

Kariton commented Dec 1, 2024

it would be helpful to override the "savename" in script-output.

i use bash to fetch the last changed save game and run mapshot cli on it.
this results in a bunch of autosaveX named mapshots.

# /mapshot/factorio/script-output/mapshot# ls -la
drwxr-xr-x. 7 root root  7 Nov 30 18:07 .
drwxr-xr-x. 3 root root  3 Nov 30 08:33 ..
drwxr-xr-x. 6 root root 11 Dec  1 02:12 _autosave1
drwxr-xr-x. 4 root root  9 Dec  1 00:49 _autosave2
drwxr-xr-x. 6 root root 11 Dec  1 02:38 _autosave3
drwxr-xr-x. 4 root root  9 Nov 30 19:12 _autosave4
drwxr-xr-x. 6 root root 11 Dec  1 02:56 _autosave5

i would love to see a parameter to override this and define a common folder for all mapshots.

@Kariton
Copy link
Author

Kariton commented Dec 3, 2024

i found a way to make it work within my bash script.

move_generated_mapshot() {
	local mapshot_save_path="${1}" # full path to mapshot generated content
	local mapshot_directory_name="${2}" # desired name for "savegame"
	local factorio_save_file_name="${3}" # resulting filename from 'latest' save discovery
	local mapshot_json

	printf "Moving generated mapshot to '%s'...\n" "${mapshot_save_path}"

	mkdir --parents "${mapshot_save_path}"
	mv "${MAPSHOT_OUTPUT_DIRECTORY}/${factorio_save_file_name}"/* "${mapshot_save_path}"

	find "${mapshot_save_path}" -mindepth 2 -maxdepth 2 -type f -name "mapshot.json" |
		while read -r mapshot_json; do
			jq --arg savename "${MAPSHOT_SAVE_NAME}" '.savename = $savename' "${mapshot_json}" >"${mapshot_json}.tmp" &&
				mv "${mapshot_json}.tmp" "${mapshot_json}"
		done
}

move_generated_mapshot "factorio/script-output/mapshot/_autosave5" "my-save-name" "_autosave5"

factorio_save_file_name is the discovered latest save game.
mapshot_save_path is a composition of different variables i use in my script for further processing.
mapshot_directory_name is the name under which the generated mapshots are saved and displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant