@rbxts/sound-manager 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/out/core/createSoundRegistry.luau +19 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ npm install @rbxts/sound-manager
|
|
|
40
40
|
|
|
41
41
|
### ⚡ Starting with Sound Manager
|
|
42
42
|
|
|
43
|
-
Sound-Manager uses [`createSoundRegistry`]() and [`createSoundCategoryRegistry`]() to create sounds and categories.
|
|
43
|
+
Sound-Manager uses [`createSoundRegistry`](https://dev-lukas0.github.io/Sound-Manager/docs/reference/create-sound-registry) and [`createSoundCategoryRegistry`](https://dev-lukas0.github.io/Sound-Manager/docs/reference/create-sound-category-registry) to create sounds and categories.
|
|
44
44
|
|
|
45
45
|
```ts
|
|
46
46
|
import { createSoundRegistry } from "@rbxts/sound-manager";
|
|
@@ -83,6 +83,10 @@ local function createSoundRegistry(definitions)
|
|
|
83
83
|
local function stop(name, spatial)
|
|
84
84
|
if not spatial then
|
|
85
85
|
local sound = folder:FindFirstChild(name)
|
|
86
|
+
if not sound then
|
|
87
|
+
warn(`{name} not found! Tip: Preload the sound first before using it.`)
|
|
88
|
+
return nil
|
|
89
|
+
end
|
|
86
90
|
local _result = sound
|
|
87
91
|
if _result ~= nil then
|
|
88
92
|
_result:Stop()
|
|
@@ -122,6 +126,10 @@ local function createSoundRegistry(definitions)
|
|
|
122
126
|
local config = definitions[soundName]
|
|
123
127
|
if not spatial or not spatial.emitters then
|
|
124
128
|
local sound = folder:FindFirstChild(soundName)
|
|
129
|
+
if not sound then
|
|
130
|
+
warn(`{soundName} not found! Tip: Preload the sound first before using it.`)
|
|
131
|
+
return nil
|
|
132
|
+
end
|
|
125
133
|
sound.Volume = 0
|
|
126
134
|
sound:Play()
|
|
127
135
|
local step = 0.05
|
|
@@ -168,6 +176,7 @@ local function createSoundRegistry(definitions)
|
|
|
168
176
|
if not spatial or not spatial.emitters then
|
|
169
177
|
local sound = folder:FindFirstChild(soundName)
|
|
170
178
|
if not sound then
|
|
179
|
+
warn(`{soundName} not found! Tip: Preload the sound first before using it.`)
|
|
171
180
|
return nil
|
|
172
181
|
end
|
|
173
182
|
local startVolume = sound.Volume
|
|
@@ -218,7 +227,8 @@ local function createSoundRegistry(definitions)
|
|
|
218
227
|
]]
|
|
219
228
|
local function reset(sound)
|
|
220
229
|
local _sound = folder:FindFirstChild(sound)
|
|
221
|
-
if not
|
|
230
|
+
if not _sound then
|
|
231
|
+
warn(`{sound} not found! Tip: Preload the sound first before using it.`)
|
|
222
232
|
return nil
|
|
223
233
|
end
|
|
224
234
|
_sound.TimePosition = 0
|
|
@@ -245,7 +255,8 @@ local function createSoundRegistry(definitions)
|
|
|
245
255
|
]]
|
|
246
256
|
local function setTimePosition(sound, timePosition)
|
|
247
257
|
local _sound = folder:FindFirstChild(sound)
|
|
248
|
-
if not
|
|
258
|
+
if not _sound then
|
|
259
|
+
warn(`{sound} not found! Tip: Preload the sound first before using it.`)
|
|
249
260
|
return nil
|
|
250
261
|
end
|
|
251
262
|
_sound.TimePosition = timePosition
|
|
@@ -279,7 +290,8 @@ local function createSoundRegistry(definitions)
|
|
|
279
290
|
local config = definitions[sound]
|
|
280
291
|
if not spatial or spatial.emitters then
|
|
281
292
|
local _sound = folder:FindFirstChild(sound)
|
|
282
|
-
if not
|
|
293
|
+
if not _sound then
|
|
294
|
+
warn(`{sound} not found! Tip: Preload the sound first before using it.`)
|
|
283
295
|
return nil
|
|
284
296
|
end
|
|
285
297
|
_sound.Volume = volume
|
|
@@ -315,6 +327,7 @@ local function createSoundRegistry(definitions)
|
|
|
315
327
|
if not spatial then
|
|
316
328
|
local _sound = folder:WaitForChild(sound)
|
|
317
329
|
if not _sound then
|
|
330
|
+
warn(`{sound} not found! Tip: Preload the sound first before using it.`)
|
|
318
331
|
return nil
|
|
319
332
|
end
|
|
320
333
|
_sound.Ended:Connect(callback)
|
|
@@ -345,6 +358,9 @@ local function createSoundRegistry(definitions)
|
|
|
345
358
|
]]
|
|
346
359
|
local function isPlaying(sound)
|
|
347
360
|
local _sound = folder:FindFirstChild(sound)
|
|
361
|
+
if not _sound then
|
|
362
|
+
warn(`{sound} not found! Tip: Preload the sound first before using it.`)
|
|
363
|
+
end
|
|
348
364
|
if _sound.IsPlaying == true then
|
|
349
365
|
return true
|
|
350
366
|
else
|