saveStartingPosition
Definition
-- @/lua/ge/extensions/gameplay/crawl/saveSystem.lua:392
M.saveStartingPosition = function(startingPosition, filePath)
if not startingPosition then
log('E', logTag, 'No starting position to save')
return false
end
if not filePath then
log('E', logTag, 'No file path provided for starting position')
return false
end
local serializedData = serializeStartingPosition(startingPosition)
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.startingPositions then
cache.startingPositions = {}
end
cache.startingPositions[filePath] = startingPosition
return true
else
log('E', logTag, 'Failed to save starting position to: ' .. filePath)
return false
end
end
Callers
@/lua/ge/extensions/editor/crawlEditor/missionPortTool.lua
local startingPositionFile = levelCrawlDir .. missionName .. ".startingPosition.json"
local startingPositionSuccess = gameplay_crawl_saveSystem.saveStartingPosition(startingPosition, startingPositionFile)
@/lua/ge/extensions/editor/crawlEditor.lua
elseif objectType == "startingPosition" then
gameplay_crawl_saveSystem.saveStartingPosition(object, newFilePath)
end
if newObject then
success = gameplay_crawl_saveSystem.saveStartingPosition(newObject, filePath)
end
if startingPosition._dirty then
if gameplay_crawl_saveSystem.saveStartingPosition(startingPosition, startingPosition._filePath) then
savedCount = savedCount + 1
if selectedStartingPosition then
if gameplay_crawl_saveSystem.saveStartingPosition(selectedStartingPosition, selectedStartingPosition._filePath) then
selectedStartingPosition._dirty = false