Created
August 25, 2025 12:41
-
-
Save Yanis002/6ee256dab6300d15a3beb6cbb2cf2d5c to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env python3 | |
| import ndspy.narc as narc | |
| import ndspy.lz10 as lz10 | |
| from pathlib import Path | |
| def main(name: str): | |
| decomp = Path("../github/st").resolve() | |
| extracted = decomp / "extract" / "eur" | |
| folder_to_process = extracted / "files" / "Map" / name | |
| narcs: list[Path] = [] | |
| assert decomp.exists() | |
| assert extracted.exists() | |
| assert folder_to_process.exists() | |
| for narc_path in folder_to_process.rglob("*.bin"): | |
| with narc_path.open("rb") as file: | |
| start = file.read(0x10) | |
| file.seek(0) | |
| if b"NARC" in start: | |
| narcs.append(narc_path) | |
| for narc_path in narcs: | |
| try: | |
| data = narc.NARC.fromFile(narc_path) | |
| except ValueError: | |
| data = narc.NARC(lz10.decompressFromFile(narc_path)) | |
| out_dir = Path(f"./extracted/{name}").resolve() | |
| out_dir.mkdir(exist_ok=True) | |
| for i, file in enumerate(data.files): | |
| out_path = out_dir / narc_path.stem | |
| out_path.mkdir(exist_ok=True) | |
| (out_path / f"{narc_path.stem}_file_{i}.bin").write_bytes(file) | |
| if __name__ == "__main__": | |
| main("f_htown") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment