Last active
August 7, 2026 03:13
-
-
Save david-wm-sanders/f7609a3fbb0bcfeb5fb06b5150736fa7 to your computer and use it in GitHub Desktop.
Script to add name tags to RWR special crates
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
| import xml.etree.ElementTree as XmlET | |
| from pathlib import Path | |
| STEAMLIB_DIR = "C:/Program Files (x86)/Steam" | |
| RWR_INSTALL_DIR = Path(STEAMLIB_DIR) / "steamapps/common/RunningWithRifles" | |
| VANILLA_PKG_DIR = RWR_INSTALL_DIR / f"media/packages/vanilla" | |
| VANILLA_PKG_VEHICLES_DIR = VANILLA_PKG_DIR / "vehicles" | |
| CRATE_COLLECTIONS = ["special_crates*.xml", "airdrop_supply_crates.xml"] | |
| if __name__ == "__main__": | |
| for crate_collection in CRATE_COLLECTIONS: | |
| for crates_xml_path in VANILLA_PKG_VEHICLES_DIR.glob(crate_collection): | |
| print(f"Processing '{crates_xml_path.name}'...") | |
| element_tree = XmlET.parse(crates_xml_path) | |
| vehicles_elem = element_tree.getroot() | |
| for vehicle_elem in vehicles_elem.findall("vehicle"): | |
| # find all results in the vehicle, extract the instance keys, and clean them up | |
| names = (result.get("instance_key").split(".")[0].replace("_", " ") | |
| for result in vehicle_elem.findall("./event/result")) | |
| # set new name attribute in the vehicle to names concatenation | |
| vehicle_elem.set("name", ", ".join(names)) | |
| # overwrite the original file | |
| element_tree.write(crates_xml_path, encoding="utf-8", xml_declaration=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment