GE Lua Documentation

Press F to search!

saveCrawlData

Definition


-- @/lua/ge/extensions/gameplay/crawl/saveSystem.lua:469

-- Save crawl data (main entry point)
M.saveCrawlData = function(saveData, filepath)
  if not saveData then
    log('E', logTag, 'No crawl data to save')
    return false
  end

  if not filepath then
    log('E', logTag, 'No filepath provided for saving')
    return false
  end

  -- Serialize crawl data (only metadata, not the actual items)
  local serializedData = {
    name = saveData.name,
    description = saveData.description,
    icon = saveData.icon,
    metadata = saveData.metadata,
    trails = {}
  }

  -- Add trail IDs (file paths)
  for _, trail in ipairs(saveData.trails or {}) do
    if trail.id then
      table.insert(serializedData.trails, trail.id)
    end
  end

  local success = jsonWriteFile(filepath, serializedData, true)
  if success then
    return true
  else
    log('E', logTag, 'Failed to save crawl data to: ' .. filepath)
    return false
  end
end

Callers