getPlayerCrawlTrailsById
Definition
-- @/lua/ge/extensions/gameplay/crawl/saveSystem.lua:724
local function getPlayerCrawlTrailsById()
if not playerTrailsById then
local saveFolder = playerSavePathFreeroam
if career_career.isActive() then
local saveSlot, savePath = career_saveSystem.getCurrentSaveSlot()
saveFolder = savePath .. playerSavePathCareer
end
local loaded = 0
playerTrailsById = {}
-- Get all trails from the save system
local allTrails = M.getAllTrails()
for _, trail in ipairs(allTrails or {}) do
local trailId = trail._filePath or trail.id
if trailId then
-- Load save data for this trail
local saveData = jsonReadFile(saveFolder .. trailId .. ".json") or {}
-- Initialize default save data structure
saveData.bestTime = saveData.bestTime or math.huge
saveData.bestPenaltyPoints = saveData.bestPenaltyPoints or math.huge
saveData.bestTimeDate = saveData.bestTimeDate or 0
saveData.bestPenaltyPointsDate = saveData.bestPenaltyPointsDate or 0
saveData.attempts = saveData.attempts or 0
-- Create trail data structure
local trailData = {
id = trailId,
trail = trail,
saveData = saveData
}
playerTrailsById[trailId] = trailData
if next(saveData) then
loaded = loaded + 1
end
end
end
log("I", logTag, "Loaded " .. #tableKeys(playerTrailsById) .. " player crawl trails and " .. loaded .. " crawl score files.")
end
return playerTrailsById
end
Callers
@/lua/ge/extensions/gameplay/crawl/saveSystem.lua
local function onSaveCurrentSaveSlot(currentSavePath)
for id, trail in pairs(M.getPlayerCrawlTrailsById()) do
if trail._dirty then
local function getPlayerCrawlTrailById(trailId)
return M.getPlayerCrawlTrailsById()[trailId]
end