• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

mrmossycowboy

Recruit
10 Badges
Jan 15, 2024
1
2
  • Crusader Kings II
  • Cities: Skylines
  • Mount & Blade: With Fire and Sword
  • Cities: Skylines - Snowfall
  • Hearts of Iron IV: Cadet
  • Cities: Skylines - Natural Disasters
  • Knights of Honor
  • Prison Architect
  • Crusader Kings III
  • Crusader Kings III: Royal Edition
I recently started my own try at a total convercion mod for CK3, without any prior experience and realized that many things take a long time. With the help of ChatGPT (cause im a total noob at this) i made these 3 scripts that have helped me save a lot of time on repetative tasks. These all need code from your landed titles file to work.

Auto Localize: A script that takes code from your landed titles file and spits out localization for the titles of Count to Emperor e.g. "e_germania" becomes "e_germania:0 "Germania""

Barony Name Generator: Works in the same way as Auto Localize exept only for baronies and also reads a list of prefixes and suffixes to generate a random name. e.g. "b_test1" becomes "b_test1:0 "Southwind"". Assuming of that both "South" and "wind" are in your Prefix/Suffix lists.

Province History from Landed Titles: Also reads landed titles to put out a province history. In the script there are three options: Culture, Religion, and Holding. Change these to the desired variables and run the script to get all the province history. (I would recomend going into the code and change the holdings manually afterward as i assume you dont want all holdings in your TC mod to be cities)

As i said these scripts are made with the help of ChatGPT so i cant say they will work perfectly every time, but from my testing they all seem to work alright. Except for Auto Localize that sometimes skips the odd title here and there, but nothing that is too bad to go in and fix yourself.

Auto Localize
Python:
import re

def generate_localization_entries(code):
    pattern = re.compile(r'(e|k|d|c)_(\w+) = {[\s\S]*?color = { (\d+) (\d+) (\d+) }[\s\S]*?}')
    matches = pattern.findall(code)

    localization_entries = []

    for title_type, title_name, r, g, b in matches:
        localized_name = title_name.capitalize()  # You can customize this if you want a different capitalization
        entry = f'{title_type}_{title_name}:0 "{localized_name}"'
        localization_entries.append(entry)

    return localization_entries

# Your provided code
code = """

"""

localization_entries = generate_localization_entries(code)

for entry in localization_entries:
    print(entry)



Barony Name Generator
Python:
import re
import random

def generate_random_name(used_names):
    prefix_list = ['Gard', 'Fen', 'Ran', 'Gre', 'Man', 'Till', 'Sven', 'Har', 'Kas', 'Graa', 'Hel', 'Rein', 'Blaa', 'Fred', 'Alv', 'Svan', 'Geir', 'Tem', 'San', 'Ves', 'Ost', 'Or']
    suffix_list = ['lan', 'dal', 'li', 'borg', 'sten', 'bakk', 'holdt', 'gar', 'le', 'flekk', 'ferd', 'ia', 'fjo', 'vos', 'lang', 'foss']

    while True:
        random_prefix = random.choice(prefix_list)
        random_suffix = random.choice(suffix_list)
        new_name = f"{random_prefix}{random_suffix}"

        if new_name not in used_names:
            used_names.add(new_name)
            return new_name

def generate_localization(code):
    pattern = re.compile(r'b_(\w+) = {[\s\S]*?province = (\d+)[\s\S]*?}')
    matches = pattern.findall(code)

    used_names = set()
    localization_entries = []

    for match in matches:
        title_name, province_number = match
        new_name = generate_random_name(used_names)
        localization_entries.append(f'b_{title_name}:0 "{new_name}"')

    return localization_entries

# Your provided code
code = """

"""

localization_entries = generate_localization(code)

for entry in localization_entries:
    print(entry)



Province History From Landed Titles
Python:
import re

def extract_province_info(code):
    pattern = re.compile(r'province = (\d+)[\s\S]*?color = { (\d+) (\d+) (\d+) }[\s\S]*?')
    matches = pattern.findall(code)
    
    result = {}
    
    for match in matches:
        province_number, r, g, b = match
        result[int(province_number)] = {
            'color': (int(r), int(g), int(b)),
            'culture': 'english',  # You can replace this with the actual culture value
            'religion': 'cahtolic',  # You can replace this with the actual religion value
            'holding': 'no_holding'  # You can replace this with the actual holding value
        }
    
    return result

# Your provided code from the landed titles file
code = """

"""

province_info = extract_province_info(code)

for province, info in province_info.items():
    print(f"{province} = {{\n\tculture = {info['culture']}\n\treligion = {info['religion']}\n\tholding = {info['holding']}\n}}")
 
Last edited:
  • 1Love
  • 1Like
Reactions: