Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sean_kenny/eu4-text-file-to-json-parser-js

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sean_kenny/eu4-text-file-to-json-parser-js

A library for reading text files in the format EU4 encodes it's game data in.

  • 0.1.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

eu4-text-file-to-json-parser-js

This is a TypeScript library which contains a function which converts the types of text files used for modding the game Europa Universalis 4 to a JSON format for easier use.

Version Downloads/week

Installation and Usage

$ npm install --save-dev @sean_kenny/eu4-text-file-to-json-parser-js
# or
$ yarn add -D @sean_kenny/eu4-text-file-to-json-parser-js

An output can then be generated by calling the parseEu4TextFileToJson function, which is the only function in the library.

const { outputJSONData } = await parseEu4TextFileToJson({
  inputFilePath: '/path/to/your/file/your_file.txt'
})

Some sample inputs and outputs

The following are some examples of data that can be contained in your_file.txt and the JSON they will parse to.

#Cannor
damesneck_sea_area = {
	1293 1276 1275 1274 1269 1270 1272 1271
}

dameshead_sea_area = {
	1268 1928 1253 1266 1257 1267 1252 1926 1255 1258
}

bay_of_wines_sea_area = {
	1278 1297 1292 1471 1472 1291
}
{
  "damesneck_sea_area": [ "1293", "1276", "1275", "1274", "1269", "1270", "1272", "1271" ],
  "dameshead_sea_area": [ "1268", "1928", "1253", "1266", "1257", "1267", "1252", "1926", "1255", "1258" ],
  "bay_of_wines_sea_area": ["1278", "1297", "1292", "1471", "1472", "1291"]
}
# province id = rotation in degrees, 0 is pointing right, then ccw)
# can be reloaded ingame by cmd: reloadtradewinds

1473 = 180
1568 = 200
1565 = 180
1583 = 190

1480 = 170
1484 = 190
1571 = 175

1498 = 250
1585 = 220
1599 = 220
1590 = 250
1589 = 190
{
  "1473": "180",
  "1480": "170",
  "1484": "190",
  "1498": "250",
  "1565": "180",
  "1568": "200",
  "1571": "175",
  "1583": "190",
  "1585": "220",
  "1589": "190",
  "1590": "250",
  "1599": "220"
}
leechdens_region = {
	areas = {
		serpenthome_area
		spider_coast_area
		screaming_jungle_area
		middans_area
		edgewoods_area
		ungoths_trail_area
		red_isle_area
		leechdens_maw_area
	}
	monsoon = {
		00.12.01
		00.12.30
	}
	monsoon = {
		00.01.01
		00.04.30
	}
}
{
  "leechdens_region": {
    "areas": [
      "serpenthome_area",
      "spider_coast_area",
      "screaming_jungle_area",
      "middans_area",
      "edgewoods_area",
      "ungoths_trail_area",
      "red_isle_area",
      "leechdens_maw_area"
    ],
    "monsoon": ["00.12.01", "00.12.30", "00.01.01", "00.04.30"]
  }
}
tree = { 3 4 7 10 }
{
  "tree": ["3", "4", "7", "10"]
}
add_core = I43
culture = green_orc
add_core = I34
{
  "add_core": ["I43", "I34"],
  "culture": "green_orc"
}
is_city = yes
add_permanent_province_modifier = {
	name = harimari_minority_coexisting_small
	duration = -1
}
add_permanent_province_modifier = {
	name = temple_complex
	duration = -1
}
{
  "is_city": "yes",
  "add_permanent_province_modifier": [
    { "name": "harimari_minority_coexisting_small", "duration": "-1" },
    { "name": "temple_complex", "duration": "-1" }
  ]
}

More full examples are available by perusing the /test/sample-inputs and /test/expected-outputs folders in the repository.

Acknowledgements

All sample input files which are used for testing are pulled directly from the ab937cf899b75f74662a17574bd0d46072793beb version of Anbennar which was published to Bitbucket on August 23rd 2024. All credit for those files goes to their creator.

You're welcome to use this library for anything you'd like. I don't think there's a set spec for the files Paradox Interactive uses for their text files so I wouldn't be surprised if there's some files this doesn't parse correctly. Please reach out if you have a file in the EU4 game files or a particular mod which is not processed properly by this library and I'd be happy to work on something to make it work for you.

FAQs

Package last updated on 27 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc