Jump to content
Age of History 3
Smeysya

Python Script for transferring provinces to JSON from TXT file (From old map editor)

Recommended Posts

Posted (edited)

Hello everyone!

I have written a simple script that will help a lot of modders to transfer their own maps to the new map editor.

All you need is to install the latest version of Python to run the script.

Put the program file in the same folder as the text file "mapAoC2_v2.txt" (if you don't know where it is yet look here "Map Editor 2.0\editor_data\Provinces").

Just run a programm and it will give you a complete JSON file in the same folder. If your text file is called differently, the program will ask you to specify the name of this file without the extension/postscript ".txt"

Then simply replace the JSON file with the path MapEditor_2\MapName\data, in the folder of the new map editor for AoH3.

If you dont want to download a complete .py file, you can just copy code below:

Quote

 

try:
    a=open("mapAoC2_v2.txt","r")
except:
    filename=str(input('There is a problem finding the file, please specify the filename (without .txt): '))
    a=open(filename,"r")

switch=1
PrID=0
b=open("ProvincePoints.json", "w+")
b.write("{\n")
b.write("    Age_of_History: Data,\n")
b.write("        Data: [\n")

for i in a:
    if switch>0:
        b.write("        {\n")
        b.write("            iProvinceID: "+str(PrID)+",\n")
        b.write("            lPointsX: ["+i[:-1]+"],\n")
    else:
        b.write("            lPointsY: ["+i[:-1]+"]\n")
        b.write("        },\n")
        PrID+=1
    switch*=-1

b.write("    ]\n")
b.write("}")

 

 

Also, a small mistake from me is that the program deletes one character in the last line. I recommend manually adding the missing digit (if you dont last province will have broken borders). Sorry for that issue.

 

There .py file:

transfer.py

Edited by Smeysya
Addition

Share this post


Link to post
Share on other sites

Posted (edited)
16 hours ago, Smeysya said:

Hello everyone!

I have written a simple script that will help a lot of modders to transfer their own maps to the new map editor.

All you need is to install the latest version of Python to run the script.

Put the program file in the same folder as the text file "mapAoC2_v2.txt" (if you don't know where it is yet look here "Map Editor 2.0\editor_data\Provinces").

Just run a programm and it will give you a complete JSON file in the same folder. If your text file is called differently, the program will ask you to specify the name of this file without the extension/postscript ".txt"

Then simply replace the JSON file with the path MapEditor_2\MapName\data, in the folder of the new map editor for AoH3.

If you dont want to download a complete .py file, you can just copy code below:

 

Also, a small mistake from me is that the program deletes one character in the last line. I recommend manually adding the missing digit (if you dont last province will have broken borders). Sorry for that issue.

 

There .py file:

transfer.py 638 B · 1 download

Cool script! Earlier, I tried to create a Tkinter GUI script to quickly change the coordinates of provinces (which would even allow editing provinces using Android, although with great problems), at that time I managed to determine that the necessary line numbers for each prov ID are calculated using the formulas X = 2*n+1 and Y=2*n+2, where n is a prov ID, X and Y are lines with x and y coordinates.

Screenshot_2024-06-02-11-51-02-42_c759c44d10a956b96f85cc66750ff86e.jpg

Edited by Mirolit

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Age of History Games