Skip to content

Commit

Permalink
Use a more friendly error message for empty sound names.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoikas committed Jun 15, 2024
1 parent eb0c5f9 commit c6b5422
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion korman/nodes/node_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,10 @@ def _convert_sound_emitter_msg(self, exporter, so):
# Remember that 3D stereo sounds are exported as two emitters...
# But, if we only have one sound attached, who cares, we can just address the message to all
msg = plSoundMsg()
sound_keys = tuple(soundemit.get_sound_keys(exporter, self.sound_name))
try:
sound_keys = tuple(soundemit.get_sound_keys(exporter, self.sound_name))
except ValueError as ex:
self.raise_error(f"Invalid sound specified {ex}")
indices = frozenset((i[1] for i in sound_keys))

if indices:
Expand Down
4 changes: 3 additions & 1 deletion korman/properties/modifiers/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,10 @@ def _handle_stereize_lfm(self, exporter, child_bo: bpy.types.Object, parent_so:
lfm_key.object.addStereizer(stereizer.key)

def get_sound_keys(self, exporter, name=None, sound=None) -> Iterator[Tuple[plKey, int]]:
assert name or sound
assert name is not None or sound is not None
if sound is None:
if not name:
raise ValueError(f"{self.id_data.name}: (No sound specified)")
sound = next((i for i in self.sounds if i.name == name), None)
if sound is None:
raise ValueError(f"{self.id_data.name}: Sound {name}")
Expand Down

0 comments on commit c6b5422

Please sign in to comment.