FluffyMaguro / AoE4_Overlay

GNU General Public License v3.0
139 stars 22 forks source link

\n not working properly in build order notes #22

Closed TheMarcosP closed 1 year ago

TheMarcosP commented 1 year ago

I want to be able to have multiple task in one tab so i tried to do something like this inside of a note "notes": [ build @building_economy/mill.png@ \n one to @resource/resource_gold.png@ \n @age/age_2.png@ set all back to @resource/sheep.png@ ]

but it does not work as expected. instead it only moves the next icon down

CraftySalamander commented 1 year ago

Hi. This is how you can write it:

"notes": [
    "build @building_economy/mill.png@",
    "one to @resource/resource_gold.png@",
    "@age/age_2.png@ set all back to @resource/sheep.png@"
]

For more instructions, you can read this page (section "Designing a build order").

t1z14n commented 1 year ago

I wrote this python code with chatgpt to fix it, maybe it works for you as well

import json
import pyperclip

# Read data from clipboard
clipboard_data = pyperclip.paste()
data = json.loads(clipboard_data)

# Process data
for item in data["build_order"]:
    item["notes"] = [note.replace("\n", "") for note in item["notes"]]
    item["notes"] = [note.replace("  ", "") for note in item["notes"]]

# Copy updated data to clipboard
updated_data = json.dumps(data, indent=4)
pyperclip.copy(updated_data)

"""
This code uses the pyperclip module to read the data from the clipboard using the pyperclip.paste() method. 
It then processes the data using the same loop as before to remove the newline characters from the "notes" field.
Finally, it uses the json.dumps() method to pretty-print the updated data with the indent parameter set to 4, 
and then copies the updated data back to the clipboard using the pyperclip.copy() method.
"""
TheMarcosP commented 1 year ago

I wrote this python code with chatgpt to fix it, maybe it works for you as well

import json
import pyperclip

# Read data from clipboard
clipboard_data = pyperclip.paste()
data = json.loads(clipboard_data)

# Process data
for item in data["build_order"]:
    item["notes"] = [note.replace("\n", "") for note in item["notes"]]
    item["notes"] = [note.replace("  ", "") for note in item["notes"]]

# Copy updated data to clipboard
updated_data = json.dumps(data, indent=4)
pyperclip.copy(updated_data)

"""
This code uses the pyperclip module to read the data from the clipboard using the pyperclip.paste() method. 
It then processes the data using the same loop as before to remove the newline characters from the "notes" field.
Finally, it uses the json.dumps() method to pretty-print the updated data with the indent parameter set to 4, 
and then copies the updated data back to the clipboard using the pyperclip.copy() method.
"""

If you are refering to the bug where the json is full of "\n":, then yeah that will do it, nice one

t1z14n commented 1 year ago

yeah sorry my bad haha, I actually misread what you wrote