GE Lua Documentation

Press F to search!

loadCrawlData

Definition


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

-- Load crawl data (main entry point)
M.loadCrawlData = function(filename)
  if not filename then
    log('E', logTag, 'No filename provided for loading')
    return nil
  end

  log('D', logTag, 'Attempting to load crawl data from: ' .. tostring(filename))

  local data = jsonReadFile(filename)
  if not data then
    log('E', logTag, 'Failed to read crawl data file: ' .. filename)
    return nil
  end

  local crawlData = {
    name = data.name,
    description = data.description or "",
    icon = data.icon or "rockCrawling01",
    metadata = data.metadata or {
      created = os.date(),
      modified = os.date(),
      description = "Crawl system data"
    },
    trails = {}
  }

  -- Load trails using the new getter system
  for i, trailId in ipairs(data.trails or {}) do
    local trail = M.getTrailById(trailId)
    if trail then
      table.insert(crawlData.trails, trail)
    else
      log('W', logTag, 'Failed to load trail: ' .. trailId)
    end
  end

  log('D', logTag, 'Loaded crawl data with ' .. #crawlData.trails .. ' trails')
  return crawlData
end

Callers