Esempio n. 1
0
def set_player_name(name: str):
    f = open(path_finder.get_nwnplayer_path(), 'r')
    lines = f.readlines()

    for i in range(0, len(lines)):
        if "Player Name" in lines[i] or "player name" in lines[i]:
            lines[i] = lines[i][0:lines[i].index('=')+1] + name + '\n'
    f.close()

    f = open(path_finder.get_nwnplayer_path(), 'w')
    f.writelines(lines)
    # do the remaining operations on the file
    f.close()
Esempio n. 2
0
def _load_player_name() -> str:
    try:
        with open(path_finder.get_nwnplayer_path()) as nwnplayer_conf:
            for line in nwnplayer_conf:
                if "Player Name" in line or "player name" in line:
                    return line[line.index('=') + 1:-1]
    except:
        print("Couldn't open NWN config file.")

    return " "