https://github.com/rakaly/eu4save
Library to ergonomically work with EU4 saves (ironman + mp)
https://github.com/rakaly/eu4save
eu4 ironman paradox
Last synced: about 1 month ago
JSON representation
Library to ergonomically work with EU4 saves (ironman + mp)
- Host: GitHub
- URL: https://github.com/rakaly/eu4save
- Owner: rakaly
- License: mit
- Created: 2020-08-09T16:22:13.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-12-23T04:18:55.000Z (5 months ago)
- Last Synced: 2025-12-24T19:24:04.871Z (5 months ago)
- Topics: eu4, ironman, paradox
- Language: Rust
- Homepage:
- Size: 480 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
 [](https://docs.rs/eu4save) [](https://crates.io/crates/eu4save)
# EU4 Save
EU4 Save is a library to ergonomically work with EU4 saves (ironman + mp).
```rust
use eu4save::{Eu4File, Encoding, CountryTag, SegmentedResolver};
let data = std::fs::read("assets/saves/eng.txt.compressed.eu4")?;
let file = Eu4File::from_slice(&data)?;
let save = file.parse_save(&SegmentedResolver)?;
assert_eq!(file.encoding(), Encoding::TextZip);
assert_eq!(save.meta.player, "ENG".parse()?);
```
## Querying
Even once decoded, the data might be too low level. For example a country can
have an income ledger that looks like:
```ignore
income = { 1.000 0 2.000 0.000 1.500 }
```
While the structure will decoded successfully into a vector, the context of
what each index means is missing. What value represents the income from
trade?
To help solve questions like these, the `Query` API was created
```rust
use eu4save::{Eu4Extractor, Encoding, CountryTag, query::Query};
let data = std::fs::read("assets/saves/eng.txt.compressed.eu4")?;
let file = Eu4File::from_slice(&data)?;
let save = file.parse_save(&EnvTokens)?;
let save_query = Query::from_save(save);
let trade = save_query.country(&"ENG".parse()?)
.map(|country| save_query.country_income_breakdown(country))
.map(|income| income.trade);
assert_eq!(Some(17.982), trade);
```
## Ironman
Ironman saves are supported, but not by default, as the token resolver can't be distributed, per PDS counsel.
You may look to other projects EU4 ironman projects like ironmelt or paperman
for inspiration.