IndexError: tuple index out of range

Users who are viewing this thread

Traceback (most recent call last):
File "process_music.py", line 23, in <module>
save_tracks()
File "process_music.py", line 18, in save_tracks
file.write("%s %d %d\n"%(track[1], track[2], (track[2] | track[3])))
IndexError: tuple index out of range

Can someone explain to me why this error happens?
 
Show your entry at module_music.py which you have made.
I'm sorry I can't you show my module_music.py because I ended up deleting all the module files so I could freshly restart my project. There was no syntax error in the module_music.py but it had up to 256 tracks. Does this error happens because of too many tracks? My project is adding all the features of Brytenwalda to Floris Expanded (Wish me good luck). I added all the Brytenwalda traveling soundtracks, some tracks from Knights of Honor and Mystic Journey, and 5 more Rejenorst Media tracks.
 
Upvote 0
How can you get that syntax error if you don't have the module system anymore which causes it? If you restart your project freshly, I assume that you also have a new module system at which you will start and at which you won't have that issue yet, haven't you?
 
Upvote 0
Well, to answer your question in simple words @Hardwood - we're almost certain that this specific error message is caused by bad syntax in your module_music.py file.
We can't give you an answer more precise than this without seeing the file.
If you don't have it anymore, then that's all the info you can get.
 
Upvote 0
Well, to answer your question in simple words @Hardwood - we're almost certain that this specific error message is caused by bad syntax in your module_music.py file.
We can't give you an answer more precise than this without seeing the file.
If you don't have it anymore, then that's all the info you can get.
Ok, I Understood. I will recreate my module_music.py and I'll let you guys know if I get the same error.
 
Upvote 0
Well, to answer your question in simple words @Hardwood - we're almost certain that this specific error message is caused by bad syntax in your module_music.py file.
We can't give you an answer more precise than this without seeing the file.
If you don't have it anymore, then that's all the info you can get.
Now I realized my mistake. I forgot to add the ID of one track in ID_music.py. Sorry for wasting your time xd
 
Upvote 0
You don't add something at ID_music.py, that file gets overwritten everytime the module system gets compiled.
I added all the tracks again and I'm still getting the same error.
my module_music.py:

("arena_6", "ext_ambushed_by_khergit.mp3", mtf_module_track|mtf_looping|mtf_sit_arena, 0), # 90,5 dB

("brytenwalda_title_screen", "brytenwalda_title_screen.ogg", mtf_module_track|mtf_sit_main_title|mtf_start_immediately, 0),
("brytenwalda_capture", "brytenwalda_capture.ogg", mtf_module_track|mtf_persist_until_finished, 0),
("brytenwalda_defeated_by_neutral", "brytenwalda_defeated_by_neutral.ogg",mtf_module_track|mtf_sit_killed, 0),
("brytenwalda_defeated_by_neutral_2", "brytenwalda_defeated_by_neutral_2.ogg", mtf_module_track|mtf_sit_killed, 0),
("brytenwalda_defeated_by_neutral_3", "brytenwalda_defeated_by_neutral_3.ogg", mtf_module_track|mtf_sit_killed, 0),
("brytenwalda_c2", "brytenwalda_c2.ogg", mtf_module_track|mtf_persist_until_finished, 0),
("brytenwalda_c9", "brytenwalda_c9.ogg", mtf_module_track|mtf_persist_until_finished, 0),
("brytenwalda_c105", "brytenwalda_c105.ogg", mtf_module_track|mtf_persist_until_finished, 0),
("brytenwalda_empty_village", "brytenwalda_empty_village.ogg", mtf_module_track|mtf_persist_until_finished, 0),
("brytenwalda_encounter_hostile_nords", "brytenwalda_encounter_hostile_nords.ogg", mtf_module_track|mtf_persist_until_finished|mtf_sit_encounter_hostile, 0),
("brytenwalda_escape", "brytenwalda_escape.ogg", mtf_module_track|mtf_persist_until_finished, 0),
("brytenwalda_outdoor_beautiful_land", "brytenwalda_outdoor_beautiful_land.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_night|mtf_sit_tavern),
("brytenwalda_killed_by_khergit", "brytenwalda_killed_by_khergit.ogg", mtf_module_track|mtf_persist_until_finished|mtf_culture_3|mtf_sit_killed, 0),
("brytenwalda_killed_by_swadian", "brytenwalda_killed_by_swadian.ogg", mtf_module_track|mtf_persist_until_finished|mtf_culture_1|mtf_sit_killed, 0),
("brytenwalda_lords_hall_khergit", "brytenwalda_lords_hall_khergit.ogg", mtf_module_track|mtf_culture_3|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern|mtf_culture_all),
("brytenwalda_lords_hall_nord", "brytenwalda_lords_hall_nord.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("brytenwalda_lords_hall_swadian", "brytenwalda_lords_hall_swadian.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("brytenwalda_lords_hall_rhodok", "brytenwalda_lords_hall_rhodok.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("brytenwalda_lords_hall_vaegir", "brytenwalda_lords_hall_vaegir.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("brytenwalda_retreat", "brytenwalda_retreat.ogg", mtf_module_track|mtf_persist_until_finished|mtf_sit_killed, 0),
("brytenwalda_town_neutral", "brytenwalda_town_neutral.ogg", mtf_module_track|mtf_sit_town|mtf_sit_travel, mtf_sit_tavern|mtf_sit_night),
("brytenwalda_town_khergit", "brytenwalda_town_khergit.ogg", mtf_module_track|mtf_culture_3|mtf_sit_town|mtf_sit_travel, mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_town_nord", "brytenwalda_town_nord.ogg", mtf_module_track|mtf_culture_4|mtf_sit_town|mtf_sit_travel, mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_town_rhodok", "brytenwalda_town_rhodok.ogg", mtf_module_track|mtf_culture_5|mtf_sit_town|mtf_sit_travel, mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_town_swadian", "brytenwalda_town_swadian.ogg", mtf_module_track|mtf_culture_1|mtf_sit_town|mtf_sit_travel, mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_town_vaegir", "brytenwalda_town_vaegir.ogg", mtf_module_track|mtf_culture_2|mtf_sit_town|mtf_sit_travel, mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_travel_khergit", "brytenwalda_travel_khergit.ogg", mtf_module_track|mtf_culture_3|mtf_sit_travel, mtf_sit_town|mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_travel_neutral", "brytenwalda_travel_neutral.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_tavern|mtf_sit_night),
("brytenwalda_travel_nord", "brytenwalda_travel_nord.ogg", mtf_module_track|mtf_culture_4|mtf_sit_travel, mtf_sit_town|mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_travel_rhodok", "brytenwalda_travel_rhodok.ogg", mtf_module_track|mtf_culture_5|mtf_sit_travel, mtf_sit_town|mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_travel_swadian", "brytenwalda_travel_swadian.ogg", mtf_module_track|mtf_culture_1|mtf_sit_travel, mtf_sit_town|mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_travel_vaegir", "brytenwalda_travel_vaegir.ogg", mtf_module_track|mtf_culture_2|mtf_sit_travel, mtf_sit_town|mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_travel_sarranid", "brytenwalda_middle_eastern_travel.ogg", mtf_culture_6|mtf_sit_travel, mtf_sit_town|mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("brytenwalda_ambushed_by_sarranid", "brytenwalda_middle_eastern_action.ogg", mtf_module_track|mtf_culture_6|mtf_sit_ambushed|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_culture_all),
("brytenwalda_uncertain_homestead", "brytenwalda_uncertain_homestead.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("brytenwalda_hearth_and_brotherhood", "brytenwalda_hearth_and_brotherhood.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("brytenwalda_tragic_village", "brytenwalda_tragic_village.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("brytenwalda_victorious_evil", "brytenwalda_victorious_evil.ogg", mtf_module_track|mtf_persist_until_finished, 0),
("brytenwalda_victorious_neutral_1", "brytenwalda_victorious_neutral_1.ogg", mtf_module_track|mtf_sit_victorious, 0),
("brytenwalda_victorious_neutral_2", "brytenwalda_victorious_neutral_2.ogg", mtf_module_track|mtf_sit_victorious, 0),
("brytenwalda_victorious_neutral_3", "brytenwalda_victorious_neutral_3.ogg", mtf_module_track|mtf_sit_victorious, 0),
("brytenwalda_victorious_swadian", "brytenwalda_victorious_swadian.ogg", mtf_module_track|mtf_culture_2|mtf_sit_victorious, 0),
("brytenwalda_victorious_vaegir", "brytenwalda_victorious_vaegir.ogg", mtf_module_track|mtf_culture_2|mtf_sit_victorious, 0),
("brytenwalda_victorious_vaegir_2", "brytenwalda_victorious_vaegir_2.ogg", mtf_module_track|mtf_culture_2|mtf_sit_victorious, 0)


("glorian_sword_faith_1", "glorian_sword_faith_1.ogg", mtf_module_track|mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed, 0),
("glorian_lost_battle_2", "glorian_lost_battle_2.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("glorian_bards_tale_3", "glorian_bards_tale_3.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("glorian_handefull_of_sorrow_4", "glorian_handefull_of_sorrow_4.ogg", mtf_module_track|mtf_culture_6|mtf_sit_travel, mtf_sit_town|mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("glorian_where_my_heart_is_5", "glorian_where_my_heart_is_5.ogg", mtf_module_track|mtf_sit_feast|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_night|mtf_sit_tavern),
("glorian_castle_dance_6", "glorian_castle_dance_6.ogg", mtf_module_track|mtf_sit_feast|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_night|mtf_sit_tavern),
("glorian_knights_fall_7", "glorian_knights_fall_7.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("glorian_dove_in_the_sky_8", "glorian_dove_in_the_sky_8.ogg", mtf_module_track|mtf_sit_feast|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_night|mtf_sit_tavern),
("glorian_echo_in_eternity_9", "glorian_echo_in_eternity_9.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_night|mtf_sit_tavern),
("glorian_pride_or_pain_10", "glorian_pride_or_pain_10.ogg", mtf_module_track|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed),
("glorian_first_battle_11", "glorian_first_battle_11.ogg", mtf_module_track|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed),
("glorian_the_die_is_cast_12", "glorian_the_die_is_cast_12.ogg", mtf_module_track|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed),
("glorian_march_on_honor_13", "glorian_march_on_honor_13.ogg", mtf_module_track|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed),
("glorian_crusade_14", "glorian_crusade_14.ogg", mtf_module_track|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed),
("glorian_vultures_lair_15", "glorian_vultures_lair_15.ogg", mtf_module_track|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed),
("glorian_last_fortress_16", "glorian_last_fortress_16.ogg", mtf_module_track|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed),
("glorian_desert_flavours_17", "glorian_desert_flavours_17.ogg", mtf_module_track|mtf_culture_6|mtf_sit_travel, mtf_sit_town|mtf_sit_tavern|mtf_sit_night|mtf_culture_all),
("glorian_knights_of_honour_18", "glorian_knights_of_honour_18.ogg", mtf_module_track|mtf_persist_until_finished),
("glorian_the_7th_horn", "glorian_the_7th_horn.ogg", mtf_module_track|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed),

("michael_ferenci_a_losing_battle", "michael_ferenci_a_losing_battle.ogg", mtf_module_track|mtf_sit_fight|mtf_sit_ambushed, 0),
("michael_ferenci_ambushed", "michael_ferenci_ambushed.ogg", mtf_module_track|mtf_sit_ambushed|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight),
("michael_ferenci_reluctant_hero", "michael_ferenci_reluctant_hero.ogg", mtf_module_track|mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed, 0),
("michael_ferenci_requiem", "michael_ferenci_requiem.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("michael_ferenci_silent_intruder", "michael_ferenci_silent_intruder.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("michael_ferenci_the_great_hall", "michael_ferenci_the_great_hall.ogg", mtf_module_track|mtf_persist_until_finished|mtf_sit_victorious, 0),
("michael_ferenci_the_pilgrimage", "michael_ferenci_the_pilgrimage.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("michael_ferenci_the_triumph", "michael_ferenci_the_triumph.ogg", mtf_module_track|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed),

("rejenorst_hammer_of_war", "rejenorst_hammer_of_war.ogg", mtf_module_track|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed),
("rejenorst_in_nomine_rex", "rejenorst_in_nomine_rex.ogg", mtf_module_track|mtf_persist_until_finished|mtf_culture_1|mtf_sit_victorious, 0),
("rejenorst_jamaican_rum", "rejenorst_jamaican_rum.ogg", mtf_module_track|mtf_sit_travel, mtf_sit_town|mtf_sit_night|mtf_sit_tavern),
("rejenorst_mideastbeat", "rejenorst_mideastbeat.ogg", mtf_module_track|mtf_culture_6|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed, mtf_culture_all),
("rejenorst_victoris", "rejenorst_victoris.ogg", mtf_module_track|mtf_culture_1|mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed, mtf_culture_all),
]

my id_music.py:
track_arena_6 = 183
track_brytenwalda_title_screen = 184
track_brytenwalda_capture = 185
track_brytenwalda_defeated_by_neutral = 186
track_brytenwalda_defeated_by_neutral_2 = 187
track_brytenwalda_defeated_by_neutral_3 = 188
track_brytenwalda_c2 = 189
track_brytenwalda_c9 = 190
track_brytenwalda_c105 = 191
track_brytenwalda_empty_village = 192
track_brytenwalda_escape = 193
track_brytenwalda_outdoor_beautiful_land = 194
track_brytenwalda_killed_by_khergit = 195
track_brytenwalda_killed_by_swadian = 196
track_brytenwalda_lords_hall_khergit = 197
track_brytenwalda_lords_hall_nord = 198
track_brytenwalda_lords_hall_swadian = 199
track_brytenwalda_lords_hall_rhodok = 200
track_brytenwalda_lords_hall_vaegir = 201
track_brytenwalda_retreat = 202
track_brytenwalda_town_neutral = 203
track_brytenwalda_town_khergit = 204
track_brytenwalda_town_nord = 205
track_brytenwalda_town_rhodok = 206
track_brytenwalda_town_swadian = 207
track_brytenwalda_town_vaegir = 208
track_brytenwalda_travel_khergit = 209
track_brytenwalda_travel_neutral = 210
track_brytenwalda_travel_nord = 211
track_brytenwalda_travel_rhodok = 212
track_brytenwalda_travel_swadian = 213
track_brytenwalda_travel_vaegir = 214
track_brytenwalda_travel_sarranid = 215
track_brytenwalda_ambushed_by_sarranid = 216
track_brytenwalda_uncertain_homestead = 217
track_brytenwalda_hearth_and_brotherhood = 218
track_brytenwalda_tragic_village = 219
track_brytenwalda_victorious_evil = 220
track_brytenwalda_victorious_neutral_1 = 221
track_brytenwalda_victorious_neutral_2 = 222
track_brytenwalda_victorious_neutral_3 = 223
track_brytenwalda_victorious_swadian = 224
track_brytenwalda_victorious_vaegir = 225
track_brytenwalda_victorious_vaegir_2 = 226
track_glorian_sword_faith_1 = 227
track_glorian_lost_battle_2 = 228
track_glorian_bards_tale_3 = 229
track_glorian_handefull_of_sorrow_4 = 230
track_glorian_where_my_heart_is_5 = 231
track_glorian_castle_dance_6 = 232
track_glorian_knights_fall_7 = 233
track_glorian_dove_in_the_sky_8 = 234
track_glorian_echo_in_eternity_9 = 235
track_glorian_pride_or_pain_10 = 236
track_glorian_first_battle_11 = 237
track_glorian_the_die_is_cast_12 = 238
track_glorian_march_on_honor_13 = 239
track_glorian_crusade_14 = 240
track_glorian_vultures_lair_15 = 241
track_glorian_last_fortress_16 = 242
track_glorian_desert_flavours_17 = 243
track_glorian_knights_of_honour_18 = 244
track_glorian_the_7th_horn = 245
track_michael_ferenci_a_losing_battle = 246
track_michael_ferenci_ambushed = 247
track_michael_ferenci_reluctant_hero = 248
track_michael_ferenci_requiem = 249
track_michael_ferenci_silent_intruder = 250
track_michael_ferenci_the_great_hall = 251
track_michael_ferenci_the_pilgrimage = 252
track_michael_ferenci_the_triumph = 253
track_rejenorst_hammer_of_war = 254
track_rejenorst_in_nomine_rex = 255
track_rejenorst_jamaican_rum = 256
track_rejenorst_mideastbeat = 257
track_rejenorst_victoris = 258
 
Upvote 0
Without going track by track, you have at least one music entry with an additional field (known as a tuple). Which is why the error message is saying there is an index that is "out of range". They expect 4 fields and you are giving them 5.

A music entry should be formatted like
("track_name", "track_file.xxx", music_track_flag, music_continue_flag),

Look at
("rejenorst_mideastbeat", "rejenorst_mideastbeat.ogg", mtf_module_track|mtf_culture_6|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed, mtf_culture_all),
It has a mtf_culture_all flag as part of a third list of flags.

Also, you're incorrectly using your flags.

For instance, you are using mtf_culture_all in both the music_track_flag and music_continue_flag outside of the times you are adding it into the 5th field when it should always be inside music_continue_flag.

I cannot confidently tell you which flags go into which list, but Native has plenty of examples
 
Last edited:
Upvote 0
Without going track by track, you have at least one music entry with an additional field (known as a tuple). Which is why the error message is saying there is an index that is "out of range". They expect 4 fields and you are giving them 5.

A music entry should be formatted like
("track_name", "track_file.xxx", music_track_flag, music_continue_flag),

Look at
("rejenorst_mideastbeat", "rejenorst_mideastbeat.ogg", mtf_module_track|mtf_culture_6|mtf_sit_siege, mtf_sit_fight|mtf_sit_multiplayer_fight|mtf_sit_ambushed, mtf_culture_all),
It has a mtf_culture_all flag as part of a third list of flags.

Also, you're incorrectly using your flags.

For instance, you are using mtf_culture_all in both the music_track_flag and music_continue_flag outside of the times you are adding it into the 5th field when it should always be inside music_continue_flag.

I cannot confidently tell you which flags go into which list, but Native has plenty of examples
I have found my mistake. the error happened because I didn't put ", 0" after "mtf_persist_until_finished" on this line:
("glorian_knights_of_honour_18", "glorian_knights_of_honour_18.ogg", mtf_module_track|mtf_persist_until_finished),
corrected line:
("glorian_knights_of_honour_18", "glorian_knights_of_honour_18.ogg", mtf_module_track|mtf_persist_until_finished, 0),
also, I did not write those music-type flags on my own I just copied them from different tracks because I didn't need to manually write them all.
 
Upvote 0
Back
Top Bottom