From c6b542225fcf5a463c1d57ecfad76599405f6a2a Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 15 Jun 2024 10:28:54 -0400 Subject: [PATCH] Use a more friendly error message for empty sound names. --- korman/nodes/node_messages.py | 5 ++++- korman/properties/modifiers/sound.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/korman/nodes/node_messages.py b/korman/nodes/node_messages.py index 94db51b..af1b5e1 100644 --- a/korman/nodes/node_messages.py +++ b/korman/nodes/node_messages.py @@ -839,7 +839,10 @@ class PlasmaSoundMsgNode(idprops.IDPropObjectMixin, PlasmaMessageWithCallbacksNo # 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: diff --git a/korman/properties/modifiers/sound.py b/korman/properties/modifiers/sound.py index 477427e..7d0adca 100644 --- a/korman/properties/modifiers/sound.py +++ b/korman/properties/modifiers/sound.py @@ -691,8 +691,10 @@ class PlasmaSoundEmitter(PlasmaModifierProperties): 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}")