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 · 2 comments
Open

[FR] option to override "savename" #60

Kariton opened this issue Dec 1, 2024 · 2 comments
Labels
enhancement New feature or request

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.

@Palats
Copy link
Owner

Palats commented Dec 5, 2024

Hah, I was going to mention how the existing path is built and modifiable with prefix - but re-reading, I misunderstood the question.

So the request is to allow to customize the savename within mapshot.json, which allows in turn for the UI to group them together as desired (as UI groups mapshot entries based on the savename in mapshot.json). The case of autosave being a compelling one.

That sounds quite doable indeed; probably need something like:

  • Add a flag to mapshot render to indicate the name under which this mapshot should be grouped, independently of the actual file name.
  • Have that information passed into the mod through the overrides mechanism.
  • Write that information in mapshot.json.
  • Use it in the UI depending on the exact solution taken.

There are 2 options to consider:

  1. Keep savename as meaning "the name of the save file when rendering", and adding a new flag & field along the line of displayname. The UI would need to use displayname if present and fallback to savename otherwise.
  2. Use the existing savename as the display name and have a new field for keeping the actual name of the file. No UI changes needed, and it would probably works, as I don't think anything really cares about the file name currently.

I think I have a preference for 1. even if it requires a change to the UI, as I find the name savename to be fitting better the semantic of a filename.

[I have no plan to work on that for now. I might do it as it is not much, but it is still unlikely]

@Palats Palats added the enhancement New feature or request label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants