Skip to content
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
---------------------------------------------------------------------------------------------------
Version: 2.1.0
Date: 19-02-2025
Features:
- Add (per player) setting to automatically activate recording with main camera on new game
- Add (per player) setting to save screenshots in map seed named subdirectories
- Add (per player) setting to change screenshot format (png/jpg)
Bugfixes:
- Fix main camera producing screenshot files with wrong camera name
---------------------------------------------------------------------------------------------------
Version: 2.0.4
Date: 07-11-2024
Bugfixes:
Expand Down
11 changes: 9 additions & 2 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ local function init_new_player(index, player)
TLBE.GUI.initialize(player, storage.playerSettings[index])

player.print({ "mod-loaded" }, { r = 1, g = 0.5, b = 0 })
player.print({ "mod-loaded2" })

local playerSettings = storage.playerSettings[index]
if not playerSettings.autoRecord then
player.print({ "mod-loaded2" })
end
end

local function on_init()
Expand Down Expand Up @@ -71,7 +75,10 @@ local function on_player_created(event)
TLBE.Config.reload(event)

local player = game.players[event.player_index]
player.print({ "mod-loaded2" }, { r = 1, g = 0.5, b = 0 })
local playerSettings = storage.playerSettings[event.player_index]
if not playerSettings.autoRecord then
player.print({ "mod-loaded2" }, { r = 1, g = 0.5, b = 0 })
end

TLBE.GUI.initialize(player, storage.playerSettings[event.player_index])
end
Expand Down
6 changes: 6 additions & 0 deletions locale/en/locale.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,18 @@ tlbe-save-folder=Save location
tlbe-sequential-names=Sequential names
tlbe-show-stats=Show camera status
tlbe-use-interval=Use interval as speed setting
tlbe-auto-record=Automatic recording
tlbe-seed-subfolder=Map seed subfolder
tlbe-save-format=Image format

[mod-setting-description]
tlbe-save-folder=Relative from 'User Data Directory'
tlbe-sequential-names=Use sequential numbering per camera for the screenshot numbers. When disabled, game ticks are used for screenshot numbering.
tlbe-show-stats=This requires the Stats GUI mod to be loaded.
tlbe-use-interval=Use intervals (between frames) instead of speed gain in the camera settings. When this setting is changed, reopen camera settings to update the UI.
tlbe-auto-record=Start recording automatically with main camera on new game
tlbe-seed-subfolder=Generate a subfolder for each map seed to store screenshots in
tlbe-save-format=Format of screenshot files

[shortcut]
tlbe=Time Lapse Base Edition
Expand Down
6 changes: 5 additions & 1 deletion scripts/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function Config.reload(event)
local playerSettings = storage.playerSettings[event.player_index]
if playerSettings == nil then
playerSettings = Config.newPlayerSettings(player)
playerSettings.cameras[playerSettings.guiPersist.selectedCamera].enabled = guiSettings["tlbe-auto-record"].value
storage.playerSettings[event.player_index] = playerSettings
end

Expand All @@ -42,6 +43,9 @@ function Config.reload(event)
playerSettings.sequentialNames = guiSettings["tlbe-sequential-names"].value
playerSettings.showCameraStatus = guiSettings["tlbe-show-stats"].value
playerSettings.useInterval = guiSettings["tlbe-use-interval"].value
playerSettings.autoRecord = guiSettings["tlbe-auto-record"].value
playerSettings.seedSubfolder = guiSettings["tlbe-seed-subfolder"].value
playerSettings.saveFormat = guiSettings["tlbe-save-format"].value
---@diagnostic enable: assign-type-mismatch
end

Expand All @@ -55,7 +59,7 @@ function Config.newPlayerSettings(player)
}

local camera = Camera.newCamera(player, {})
camera.name = "main"
Camera.setName(camera, "main")
camera.trackers = { trackers[1], trackers[2], trackers[3] }

return {
Expand Down
25 changes: 23 additions & 2 deletions scripts/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,35 @@ function Main.takeScreenshot(player, playerSettings, camera, activeTracker, forc
alwaysDay = nil
end

local savePath
if playerSettings.seedSubfolder then
savePath = string.format(
"%s/%s/%d/%010d-%s.%s",
Comment on lines +170 to +171
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should store (cache) savePath in playerSettings...? 🤔

There are so many components to build the path and only the screenshotNumber is changing each save. All the others are static and only change when the player settings are changed.

Maybe it is better to cache this outside of playerSettings, as we then initialize on startup and do not require a migration to existing saves...

Copy link
Owner

@veger veger Feb 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll create a ticket for this, as it is a separate issue and should not be part of this PR.

Camera name is also part of it, so caching this properly requires more changes than I initially imagined...
It is probably not worth it (especially with the risk of forgetting of updating the cached path in some scenario).

playerSettings.saveFolder,
camera.saveFolder,
game.default_map_gen_settings.seed,
screenshotNumber,
camera.saveName,
playerSettings.saveFormat
)
else
savePath = string.format(
"%s/%s/%010d-%s.%s",
playerSettings.saveFolder,
camera.saveFolder,
screenshotNumber,
camera.saveName,
playerSettings.saveFormat
)
end

game.take_screenshot {
by_player = player,
surface = camera.surfaceName or game.surfaces[1],
position = camera.centerPos,
resolution = { camera.width, camera.height },
zoom = camera.zoom,
path = string.format("%s/%s/%010d-%s.png", playerSettings.saveFolder, camera.saveFolder, screenshotNumber
, camera.saveName),
path = savePath,
show_entity_info = camera.entityInfo,
show_gui = camera.showGUI,
allow_in_replay = true,
Expand Down
22 changes: 22 additions & 0 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@ data:extend(
setting_type = "runtime-per-user",
default_value = false,
order = "9"
},
{
type = "bool-setting",
name = "tlbe-auto-record",
setting_type = "runtime-per-user",
default_value = false,
order = "13"
},
{
type = "bool-setting",
name = "tlbe-seed-subfolder",
setting_type = "runtime-per-user",
default_value = false,
order = "4"
},
{
type = "string-setting",
name = "tlbe-save-format",
setting_type = "runtime-per-user",
default_value = "png",
allowed_values = { "png", "jpg" },
order = "2"
}
}
)