Created
October 29, 2025 10:12
-
-
Save wjt/73bf147db16ba89db75868bf4a8113af to your computer and use it in GitHub Desktop.
Kludgy script to diff the TileMapLayers in two versions of a scene
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: The Threadbare Authors | |
| # SPDX-License-Identifier: MPL-2.0 | |
| @tool | |
| extends EditorScript | |
| const OLD = "res://orig.tscn" | |
| const NEW = "res://scenes/quests/lore_quests/quest_001/3_stealth_level/stealth_level.tscn" | |
| func _run() -> void: | |
| var old: Node = load(OLD).instantiate(PackedScene.GenEditState.GEN_EDIT_STATE_INSTANCE) | |
| var new: Node = load(NEW).instantiate(PackedScene.GenEditState.GEN_EDIT_STATE_INSTANCE) | |
| var old_tmls := old.find_children("", "TileMapLayer") | |
| var new_tmls := new.find_children("", "TileMapLayer") | |
| assert(old_tmls.size() == new_tmls.size()) | |
| for i: int in range(old_tmls.size()): | |
| var old_tml: TileMapLayer = old_tmls[i] | |
| var new_tml: TileMapLayer = new_tmls[i] | |
| var old_path := old.get_path_to(old_tml) | |
| var new_path := new.get_path_to(new_tml) | |
| assert(old_path == new_path, "{0} != {1}" % [old_path, new_path]) | |
| var old_used_cells: Array[Vector2i] = old_tml.get_used_cells() | |
| var new_used_cells: Array[Vector2i] = new_tml.get_used_cells() | |
| var removed: Array[Vector2i] | |
| var added: Array[Vector2i] | |
| var changed: Array[Vector2i] | |
| for cell: Vector2i in old_used_cells: | |
| if not new_used_cells.has(cell): | |
| removed.push_back(cell) | |
| elif ( | |
| old_tml.get_cell_source_id(cell) != new_tml.get_cell_source_id(cell) | |
| or | |
| old_tml.get_cell_atlas_coords(cell) != new_tml.get_cell_atlas_coords(cell) | |
| or | |
| old_tml.get_cell_alternative_tile(cell) != new_tml.get_cell_alternative_tile(cell) | |
| ): | |
| changed.push_back(cell) | |
| for cell: Vector2i in new_used_cells: | |
| if not old_used_cells.has(cell): | |
| added.push_back(cell) | |
| if removed or added or changed: | |
| print(old_path) | |
| if removed: | |
| prints(" Removed", removed) | |
| if added: | |
| prints(" Added", added) | |
| if changed: | |
| prints(" Changed", changed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment