OutSoundForUnit
Appearance
| Environment: | Mission Scripting | |
|---|---|---|
| Function: | outSoundForUnit | |
| Function Description: | Plays a sound for a specified unit, either by unit object or unit ID. Supports both a single sound string or a table of sound strings, selecting randomly if a table is provided. Validates input to ensure the unit is valid and the sound is properly defined. | |
| File Location: | cmm.soundFunctions.lua | |
| Syntax: | CMM.outSoundForUnit( table or string UNIT , table or string: SOUND ) | |
| Return Value: | nil | |
| Parameters: | Name | Description |
| UNIT | REQUIRED, either a unit object or a unit ID string. If not valid, an error message is logged and no sound is played. | |
| SOUND | REQUIRED, either a string path to a sound file or a table of sound file paths. A random entry is selected from the table if provided; otherwise, the string is used directly. | |
| Example: | CMM.outSoundForUnit(Unit.getByName("TEST-1"), CMM.SOUNDS.XPBanked) | |
| Example Description: | Plays a sound for the unit named "TEST-1" using the XPBanked sound from CMM.SOUNDS, leveraging unit object validation and sound selection logic. | |
| Related Functions: | ||
| Notes: | ||