Browse Source

Use a more friendly error message for empty sound names.

pull/415/head
Adam Johnson 5 months ago
parent
commit
c6b542225f
  1. 5
      korman/nodes/node_messages.py
  2. 4
      korman/properties/modifiers/sound.py

5
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:

4
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}")

Loading…
Cancel
Save