From e5e80c2754083a9d14d2303c26679e37a10ff854 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 11 Aug 2026 20:09:07 -0400 Subject: [PATCH] Save editor player positions by default --- level_editor/editor.lua | 6 +++--- room.lua | 25 +------------------------ 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/level_editor/editor.lua b/level_editor/editor.lua index fbaa7e3..c242840 100644 --- a/level_editor/editor.lua +++ b/level_editor/editor.lua @@ -469,8 +469,8 @@ local function saveRoomFromEditor() return end - local savePlayerPositions = love.keyboard.isDown("lshift", "rshift") - if not currentRoom:saveToSource(name, savePlayerPositions, oldName) then + local savePlayerPositions = not love.keyboard.isDown("lshift", "rshift") + if not currentRoom:saveToSource(name, savePlayerPositions) then editorStatus = "Could not save '" .. name .. "'." return end @@ -492,7 +492,7 @@ local function saveRoomFromEditor() editorRoomName = name roomNameField:editText(name) activeField = nil - editorStatus = "Saved source level '" .. name .. "'" .. (savePlayerPositions and " with player positions." or ".") + editorStatus = "Saved source level '" .. name .. "'" .. (savePlayerPositions and " with player positions." or " without player positions.") end local function clearRuntimeSaves() diff --git a/room.lua b/room.lua index ca12edc..5fc45d4 100644 --- a/room.lua +++ b/room.lua @@ -662,32 +662,9 @@ end -- This is intentionally separate from Room:save. It is the editor's explicit -- "write this level into the project" action; gameplay autosaves must never -- call it. -function Room:saveToSource(name, savePlayerPositions, playerSourceName) +function Room:saveToSource(name, savePlayerPositions) name = name or self.name or "test" local saveTable = self:serialize(savePlayerPositions ~= false) - if savePlayerPositions == false then - -- A normal editor save keeps the authored spawn positions from the - -- existing source level. During a rename that source is still oldName. - local sourceName = playerSourceName or name - local existing = readFromSource("rooms/" .. sourceName .. ".sav") - local keptPlayer = false - if existing then - local previous = TSerial.unpack(existing) - for _, object in ipairs(previous.objects or {}) do - if object.class == "player" then - table.insert(saveTable.objects, object) - keptPlayer = true - end - end - end - -- A newly named blank level has no prior source spawn to retain. - if not keptPlayer then - for color, player in pairs(self.player) do - local pos = player:getGridPos() - table.insert(saveTable.objects, { class = "player", color = color, x = pos.x, y = pos.y }) - end - end - end local room = TSerial.pack(saveTable, nil, true) return writeToSource("rooms/" .. name .. ".sav", room) end