GE Lua Documentation

Press F to search!

saveTrail

Definition


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

-- Save functions for individual items
M.saveTrail = function(trail, filePath)
  if not trail then
    log('E', logTag, 'No trail to save')
    return false
  end

  if not filePath then
    log('E', logTag, 'No file path provided for trail')
    return false
  end

  local serializedData = serializeTrail(trail)
  if not serializedData then
    return false
  end

  local dir = string.match(filePath, "^(.*)/[^/]*$")
  if dir then
    FS:directoryCreate(dir)
  end

  local success = jsonWriteFile(filePath, serializedData, true)
  if success then
    -- Update cache
    if not cache.trails then
      cache.trails = {}
    end
    cache.trails[filePath] = trail
    return true
  else
    log('E', logTag, 'Failed to save trail to: ' .. filePath)
    return false
  end
end

Callers

@/lua/ge/extensions/editor/crawlEditor.lua
    if updated then
      gameplay_crawl_saveSystem.saveTrail(trail, trail._filePath)
    end
    if objectType == "trail" then
      gameplay_crawl_saveSystem.saveTrail(object, newFilePath)
    elseif objectType == "path" then

  local success = gameplay_crawl_saveSystem.saveTrail(trail, newTrailFile)
  if not success then

  local success = gameplay_crawl_saveSystem.saveTrail(trail, newTrailFile)
  if not success then
    if newObject then
      success = gameplay_crawl_saveSystem.saveTrail(newObject, filePath)
    end
            elseif trail._dirty then
              if gameplay_crawl_saveSystem.saveTrail(trail, trail._filePath) then
                savedCount = savedCount + 1
            elseif trail._dirty then
              if gameplay_crawl_saveSystem.saveTrail(trail, trail._filePath) then
                savedCount = savedCount + 1
            else
              if gameplay_crawl_saveSystem.saveTrail(selectedTrail, selectedTrail._filePath) then
                selectedTrail._dirty = false
@/lua/ge/extensions/editor/crawlEditor/missionPortTool.lua
  local trailFile = missionDir .. missionName .. ".trail.json"
  local trailSuccess = gameplay_crawl_saveSystem.saveTrail(trail, trailFile)