Repository navigation
SFX Packs
Yes, the mod is called PlayerSprites, but a Sprite Pack can also play sound effects on the same events that trigger animations. There's no separate "SFX pack" file type. SFX are just part of a regular pack: you add a sounds.json file and some audio files to your pack's folder.
A pack can have sounds and animations, only animations, or only sounds (a pack with just a sounds.json and an empty/no events list works fine).
- Audio files in
.oggor.wavformat. - A
sounds.jsonfile at the root of your pack's folder, next tospr-pack.json.
MyPack/
├── pack.png
├── spr-pack.json
├── sounds.json
└── sfx/
├── jump1.ogg
├── jump2.ogg
├── land.wav
└── death.ogg
If the pack has a sounds.json, the user gets an SFX toggle and an SFX button in the pack's settings, to turn sounds on/off and control each one individually, with a play button to preview them.
The file is an object keyed by gamemode, same as the animations. Inside each gamemode, each entry is keyed by an ID:
{
"Cube": {
"NormalJump": "sfx/jump1.ogg",
"HardLanding": ["sfx/land.wav"]
},
"Ship": {
"ShipBoostStart": { "sounds": ["sfx/boost.ogg"] }
}
}Gamemode names are the same as everywhere else: Cube, Ship, Ball, etc. Sounds are per gamemode, so there's no "play this in every gamemode" section. If you want the same sound everywhere, add it to each gamemode.
Each entry can be written in three ways, from simplest to most complete:
1. A single file, as a string:
"NormalJump": "sfx/jump1.ogg"2. A list of files, as an array:
"NormalJump": ["sfx/jump1.ogg", "sfx/jump2.ogg", "sfx/jump3.ogg"]Every time the event happens, one of the files is picked at random.
3. The full form, as an object, for when you want control over the behavior:
"Jump-SFX": {
"sounds": ["sfx/jump1.ogg", "sfx/jump2.ogg"],
"triggerOn": ["NormalJump", "UFOJump"],
"ordered": true,
"resetAfter": 2.0,
"enabledByDefault": true
}In the first two forms, the entry's ID is also the event that triggers it. The extra options for control are for the full form, which is honestly the one you should be using.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
sounds |
string or array of strings | Yes | The audio file(s) to play. Paths are relative to the pack's root folder. | |
triggerOn |
string or array of strings | No | [<entry ID>] |
The event(s) that play this sound. Can be a game event, a Mod: event or a shortcut. |
ordered |
boolean | No | false |
Only matters with more than one file. Plays the files in order, one per trigger, looping back to the first one, instead of picking at random. |
resetAfter |
number (seconds) | No |
0 (never) |
Only with ordered. If this many seconds pass without the sound playing, the order resets, so the next one to play is the first file again. |
enabledByDefault |
boolean | No | true |
Whether the sound is on by default. Set it to false for sounds that may be loud or annoying, so users have to manually choose to enable them from the SFX menu. |
A few notes:
- Unlike animations,
triggerOnhere can be a plain string as well as an array. - If
triggerOnisn't set, the ID of the entry is used as the trigger. So"NormalJump": "sfx/jump1.ogg"plays whenNormalJumphappens. If you want a descriptive name instead, settriggerOn. -
resetAftercan't be negative. Setting it withoutordereddoes nothing, and the mod will log a warning. - The ID is what the user sees in the SFX menu, along with "Triggered by: ..." and "In order" if it's ordered.
Ordered sounds are good for combo-like SFX. (They were literally coded for the X4 Zero pack).
Say you have three sounds for jumping in a row:
"Cube": {
"Jumps": {
"triggerOn": ["JumpPush"],
"sounds": ["sfx/hop1.ogg", "sfx/hop2.ogg", "sfx/hop3.ogg"],
"ordered": true,
"resetAfter": 1.5
}
}The first jump plays hop1, the second hop2, the third hop3, and the fourth goes back to hop1. And if you stop jumping for more than 1.5 seconds, the next jump starts again from hop1, even if you were in the middle of the sequence.
The sequence also resets when the player respawns or restarts the level.
- Every game event from the Available Events list.
-
Shortcuts like
Mod:AnyLandingandMod:BoostOrbs(see Mod Shortcuts & Special Events). -
Mod:Death, a special event that's only for sounds. It plays when the player dies, regardless of what kind of death animation (or none) the pack uses. -
Mod:LevelComplete, plays when the player completes the level. This one works for both sounds and animations.Mod:Update,Mod:Idleand the other Mod events for animations can't trigger sounds, since they aren't actual one-time triggers that "happen".
The gamemode that matters is the gamemode the player is in when the event happens. A sound under Cube plays for cube events only.
- When an event happens, the mod looks for the first pack that is enabled (for the current level type), has SFX turned on, and has at least one enabled sound matching that event for the current gamemode.
- Sounds are loaded when a level starts, so the first time one plays there should be no delay.
- Dual mode: if both players are in the same gamemode and the same event hits both, the sound should only play once.
- Paths have to be relative to the pack's folder, and they can't go outside it (
../tricks are rejected). - Only
.oggand.wavare accepted. Any other extension makes the pack fail to load by design, with a message naming the file. - An entry needs at least one file.
- A file that doesn't exist is just skipped, and logs a warning. If none of an entry's files exist, the whole entry is ignored.
-
sounds.jsonhas to be valid JSON, obviously. - Keep sound files short and trimmed. They're loaded into memory when the level starts, so lots of long files will prolly cause lagspikes. Bad.
- Give each sound a descriptive ID (using
triggerOn) if users will be browsing them in the SFX menu. "Jump Sounds" is nicer to read than "JumpPush".