Files
alchemist-accessibility/accessibility/states/load_game.lua
T

45 lines
1.1 KiB
Lua
Raw Normal View History

2026-08-01 20:53:29 +02:00
-- states/load_game.lua
--
-- Entries are save metadata. The screen draws three columns per row: character
-- name, in-game elapsed time, and the real-world save timestamp. We speak all
-- three, in that order -- the character name is what identifies a save, but the
-- timestamps are how you tell two runs of the same character apart.
local capitalize = require("functions.capitalize")
local turnsToTime = require("functions.turnsToTime")
return {
probe = {
fn = "keypressed",
focus = "selectedOption",
list = "metadataList",
focusMayBeNil = true,
},
render = function(entry, index, total)
local parts = {}
parts[#parts + 1] = entry.characterName or "Unnamed"
if entry.turn then
local ok, turnString = pcall(function()
return capitalize(turnsToTime(entry.turn))
end)
if ok and turnString then
parts[#parts + 1] = turnString
end
end
if entry.lastUpdatedTimestamp then
local ok, dateString = pcall(os.date, "%X %x", entry.lastUpdatedTimestamp)
if ok and dateString then
parts[#parts + 1] = dateString
end
end
parts[#parts + 1] = index .. " of " .. total
return table.concat(parts, ", ")
end,
}