This script converts a CSV file with song playback rules into a JSON file that is compatible with a mod's structure.
Before running the script, ensure you have Python 3 installed on your system. No external libraries are required beyond the standard Python installation.
-
Prepare your spreadsheet: Create a spreadsheet with the specified columns and save it as a CSV file (e.g.,
songs.csv). The structure should look like this:file title priority dimension biome time_of_day is_in_combat weather is_in_cave boss_type victory_after_boss path/to/song1.ogg Spirit of the Woods 10 overworld day path/to/song2.ogg 100 TRUE path/to/song3.ogg 200 ender_dragon Column Descriptions:
file: The path to the music file (e.g.,cave/diablo1_01_intro.ogg). Required.title: The name of the song displayed in the in-game notification. If you leave this field blank, the mod will display the file name.priority: A number that determines the song's playback priority. Higher numbers mean higher priority. Required.dimension,biome,time_of_day,weather,boss_type,victory_after_boss: These fields define specific conditions for when the song should play.is_in_combat,is_in_cave,is_low_health: These should be set toTRUEorFALSE.
-
Run the script from your terminal: Open your terminal or command prompt, navigate to the directory where the script and your CSV file are located, and execute the following command:
python convert.py <input_file.csv> <output_file.json>
Example:
python convert.py songs.csv songs.json
-
Get the output: The script will generate a
songs.jsonfile in the same directory, which will contain the rules from your CSV, formatted correctly.
Ten skrypt konwertuje plik CSV z regułami odtwarzania utworów na plik JSON, który jest kompatybilny ze strukturą moda.
Przed uruchomieniem skryptu upewnij się, że masz zainstalowanego Pythona 3 na swoim systemie. Żadne zewnętrzne biblioteki nie są wymagane poza standardową instalacją Pythona.
-
Przygotuj swój arkusz kalkulacyjny: Utwórz arkusz kalkulacyjny z określonymi kolumnami i zapisz go jako plik CSV (np.
songs.csv). Struktura powinna wyglądać następująco:file title priority dimension biome time_of_day is_in_combat weather is_in_cave boss_type victory_after_boss sciezka/do/utworu1.ogg Duch Lasu 10 overworld day sciezka/do/utworu2.ogg 100 TRUE sciezka/do/utworu3.ogg 200 ender_dragon Opis kolumn:
file: Ścieżka do pliku muzycznego (np.cave/diablo1_01_intro.ogg). Wymagane.title: Nazwa utworu wyświetlana w powiadomieniu w grze. Jeśli zostawisz to pole puste, mod wyświetli nazwę pliku.priority: Numer, który określa priorytet odtwarzania utworu. Wyższe liczby oznaczają wyższy priorytet. Wymagane.dimension,biome,time_of_day,weather,boss_type,victory_after_boss: Te pola definiują konkretne warunki, kiedy utwór powinien być odtwarzany.is_in_combat,is_in_cave,is_low_health: W tych polach należy wpisaćTRUElubFALSE.
-
Uruchom skrypt z terminala: Otwórz terminal lub wiersz poleceń, przejdź do katalogu, w którym znajduje się skrypt oraz plik CSV, a następnie wykonaj następujące polecenie:
python convert.py <plik_wejsciowy.csv> <plik_wyjsciowy.json>
Przykład:
python convert.py songs.csv songs.json
-
Odbierz plik wyjściowy: Skrypt wygeneruje plik
songs.jsonw tym samym katalogu, który będzie zawierał reguły z Twojego pliku CSV w odpowiednim formacie.