Skip to content

Commit

Permalink
fix: Duplicate room button does not copy everything #185 (#228)
Browse files Browse the repository at this point in the history
* fix: Duplicate room button does not copy everything #185

* use copied items array instead of slice

---------

Co-authored-by: Adam Le Doux <[email protected]>
  • Loading branch information
fran and le-doux authored Dec 18, 2023
1 parent fb7b5b0 commit cf409a9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion editor/script/tools/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ function makeRoomTool() {
};
}

function copyItem(item) {
return {
id: item.id,
x: item.x,
y: item.y
};
}

function getAtCoord(roomId, x, y) {
var spriteId = getSpriteAt(x, y, roomId);
if (spriteId) {
Expand Down Expand Up @@ -741,11 +749,21 @@ function makeRoomTool() {
exits.push(copyExit(exit));
}

// copy items
var items = [];
for (var i in room[selectedId].items) {
var item = room[selectedId].items[i];
items.push(copyItem(item));
}

room[nextId].tilemap = tilemap;
room[nextId].walls = room[selectedId].walls.slice();
room[nextId].exits = exits;
room[nextId].endings = room[selectedId].endings.slice();
room[nextId].items = items;
room[nextId].pal = room[selectedId].pal;
room[nextId].ava = room[selectedId].ava;
room[nextId].tune = room[selectedId].tune;

selectedId = nextId;
};
Expand All @@ -769,4 +787,4 @@ function makeRoomTool() {
// TODO
};
});
}
}

0 comments on commit cf409a9

Please sign in to comment.