@rbxts/sound-manager 2.0.0 → 2.0.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.
|
@@ -20,9 +20,6 @@ local function createSoundCategoryRegistry(definitions)
|
|
|
20
20
|
|
|
21
21
|
]]
|
|
22
22
|
local function loadCategory(name)
|
|
23
|
-
if folder:FindFirstChild(name) then
|
|
24
|
-
return nil
|
|
25
|
-
end
|
|
26
23
|
local config = definitions[name]
|
|
27
24
|
local category = folder:FindFirstChild(config.category)
|
|
28
25
|
if not category then
|
|
@@ -60,9 +57,16 @@ local function createSoundCategoryRegistry(definitions)
|
|
|
60
57
|
loadCategory(name)
|
|
61
58
|
local config = definitions[name]
|
|
62
59
|
local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
|
63
|
-
local
|
|
60
|
+
local soundsFolder = ReplicatedStorage:FindFirstChild("Sounds")
|
|
61
|
+
if not soundsFolder then
|
|
62
|
+
return nil
|
|
63
|
+
end
|
|
64
|
+
local categoryFolder = soundsFolder:FindFirstChild(config.category)
|
|
65
|
+
if not categoryFolder then
|
|
66
|
+
return nil
|
|
67
|
+
end
|
|
64
68
|
for sound in pairs(config.sounds) do
|
|
65
|
-
local _sound =
|
|
69
|
+
local _sound = categoryFolder:FindFirstChild(sound)
|
|
66
70
|
if not _sound then
|
|
67
71
|
continue
|
|
68
72
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
--[[
|
|
3
|
-
*
|
|
4
|
-
* Create a sound Registry
|
|
5
|
-
* @param definitions Define the Sounds
|
|
3
|
+
*
|
|
4
|
+
* Create a sound Registry
|
|
5
|
+
* @param definitions Define the Sounds
|
|
6
6
|
|
|
7
7
|
]]
|
|
8
8
|
local function createSoundRegistry(definitions)
|
|
@@ -14,9 +14,9 @@ local function createSoundRegistry(definitions)
|
|
|
14
14
|
folder.Parent = ReplicatedStorage
|
|
15
15
|
end
|
|
16
16
|
--[[
|
|
17
|
-
*
|
|
18
|
-
* Loads a Sound
|
|
19
|
-
* @param name Define which Sound should be loaded
|
|
17
|
+
*
|
|
18
|
+
* Loads a Sound
|
|
19
|
+
* @param name Define which Sound should be loaded
|
|
20
20
|
|
|
21
21
|
]]
|
|
22
22
|
local function load(name)
|
|
@@ -40,9 +40,9 @@ local function createSoundRegistry(definitions)
|
|
|
40
40
|
sound.Parent = folder
|
|
41
41
|
end
|
|
42
42
|
--[[
|
|
43
|
-
*
|
|
44
|
-
* Plays a Sound
|
|
45
|
-
* @param name Define which Sound should be played
|
|
43
|
+
*
|
|
44
|
+
* Plays a Sound
|
|
45
|
+
* @param name Define which Sound should be played
|
|
46
46
|
|
|
47
47
|
]]
|
|
48
48
|
local function play(name)
|
|
@@ -54,9 +54,9 @@ local function createSoundRegistry(definitions)
|
|
|
54
54
|
end
|
|
55
55
|
end
|
|
56
56
|
--[[
|
|
57
|
-
*
|
|
58
|
-
* Stops a Sound
|
|
59
|
-
* @param name Define which Sound should be stopped
|
|
57
|
+
*
|
|
58
|
+
* Stops a Sound
|
|
59
|
+
* @param name Define which Sound should be stopped
|
|
60
60
|
|
|
61
61
|
]]
|
|
62
62
|
local function stop(name)
|
|
@@ -67,8 +67,8 @@ local function createSoundRegistry(definitions)
|
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
--[[
|
|
70
|
-
*
|
|
71
|
-
* Loads every Sound
|
|
70
|
+
*
|
|
71
|
+
* Loads every Sound
|
|
72
72
|
|
|
73
73
|
]]
|
|
74
74
|
local function preloadAll()
|
|
@@ -77,11 +77,11 @@ local function createSoundRegistry(definitions)
|
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
--[[
|
|
80
|
-
*
|
|
81
|
-
* Smoothly
|
|
82
|
-
* @param soundName Sound Instance
|
|
83
|
-
* @param duration Time in Seconds
|
|
84
|
-
* @param volume Volume
|
|
80
|
+
*
|
|
81
|
+
* Smoothly fade in a sound
|
|
82
|
+
* @param soundName Sound Instance
|
|
83
|
+
* @param duration Time in Seconds
|
|
84
|
+
* @param volume Volume
|
|
85
85
|
|
|
86
86
|
]]
|
|
87
87
|
local function fadeIn(soundName, duration, volume)
|
|
@@ -100,11 +100,11 @@ local function createSoundRegistry(definitions)
|
|
|
100
100
|
end)
|
|
101
101
|
end
|
|
102
102
|
--[[
|
|
103
|
-
*
|
|
104
|
-
* Smoothly fade out a sound
|
|
105
|
-
* @param soundName Sound name from Registry
|
|
106
|
-
* @param duration Time in seconds
|
|
107
|
-
* @param targetVolume Optional target volume (default 0)
|
|
103
|
+
*
|
|
104
|
+
* Smoothly fade out a sound
|
|
105
|
+
* @param soundName Sound name from Registry
|
|
106
|
+
* @param duration Time in seconds
|
|
107
|
+
* @param targetVolume Optional target volume (default 0)
|
|
108
108
|
|
|
109
109
|
]]
|
|
110
110
|
local function fadeOut(soundName, duration, targetVolume)
|
|
@@ -134,9 +134,9 @@ local function createSoundRegistry(definitions)
|
|
|
134
134
|
end)
|
|
135
135
|
end
|
|
136
136
|
--[[
|
|
137
|
-
*
|
|
138
|
-
* Reset a Sound
|
|
139
|
-
* @param sound Sound Instance
|
|
137
|
+
*
|
|
138
|
+
* Reset a Sound
|
|
139
|
+
* @param sound Sound Instance
|
|
140
140
|
|
|
141
141
|
]]
|
|
142
142
|
local function reset(sound)
|
|
@@ -147,9 +147,9 @@ local function createSoundRegistry(definitions)
|
|
|
147
147
|
_sound.TimePosition = 0
|
|
148
148
|
end
|
|
149
149
|
--[[
|
|
150
|
-
*
|
|
151
|
-
* Reset every Sound
|
|
152
|
-
* @param sound Sound Instance
|
|
150
|
+
*
|
|
151
|
+
* Reset every Sound
|
|
152
|
+
* @param sound Sound Instance
|
|
153
153
|
|
|
154
154
|
]]
|
|
155
155
|
local function resetAll(sound)
|
|
@@ -160,10 +160,10 @@ local function createSoundRegistry(definitions)
|
|
|
160
160
|
end
|
|
161
161
|
end
|
|
162
162
|
--[[
|
|
163
|
-
*
|
|
164
|
-
* Set Time Position
|
|
165
|
-
* @param sound Sound Instance
|
|
166
|
-
* @param timePosition Time Position
|
|
163
|
+
*
|
|
164
|
+
* Set Time Position
|
|
165
|
+
* @param sound Sound Instance
|
|
166
|
+
* @param timePosition Time Position
|
|
167
167
|
|
|
168
168
|
]]
|
|
169
169
|
local function setTimePosition(sound, timePosition)
|
|
@@ -174,9 +174,9 @@ local function createSoundRegistry(definitions)
|
|
|
174
174
|
_sound.TimePosition = timePosition
|
|
175
175
|
end
|
|
176
176
|
--[[
|
|
177
|
-
*
|
|
178
|
-
* Stop every Sound
|
|
179
|
-
* @param reset Define whether every Sound should also be reset?
|
|
177
|
+
*
|
|
178
|
+
* Stop every Sound
|
|
179
|
+
* @param reset Define whether every Sound should also be reset?
|
|
180
180
|
|
|
181
181
|
]]
|
|
182
182
|
local function stopAll(reset)
|
|
@@ -191,10 +191,10 @@ local function createSoundRegistry(definitions)
|
|
|
191
191
|
end
|
|
192
192
|
end
|
|
193
193
|
--[[
|
|
194
|
-
*
|
|
195
|
-
* Set Sound Volume
|
|
196
|
-
* @param sound Sound Instance
|
|
197
|
-
* @param volume Sound Volume
|
|
194
|
+
*
|
|
195
|
+
* Set Sound Volume
|
|
196
|
+
* @param sound Sound Instance
|
|
197
|
+
* @param volume Sound Volume
|
|
198
198
|
|
|
199
199
|
]]
|
|
200
200
|
local function setVolume(sound, volume)
|
|
@@ -205,9 +205,9 @@ local function createSoundRegistry(definitions)
|
|
|
205
205
|
_sound.Volume = volume
|
|
206
206
|
end
|
|
207
207
|
--[[
|
|
208
|
-
*
|
|
209
|
-
* Set the global Sound Volume
|
|
210
|
-
* @param volume Sound Volume
|
|
208
|
+
*
|
|
209
|
+
* Set the global Sound Volume
|
|
210
|
+
* @param volume Sound Volume
|
|
211
211
|
|
|
212
212
|
]]
|
|
213
213
|
local function setGlobalVolume(volume)
|
|
@@ -221,10 +221,10 @@ local function createSoundRegistry(definitions)
|
|
|
221
221
|
end
|
|
222
222
|
end
|
|
223
223
|
--[[
|
|
224
|
-
*
|
|
225
|
-
* Plays Sound on Event Callback
|
|
226
|
-
* @param name Sound Name
|
|
227
|
-
* @param callback Callback
|
|
224
|
+
*
|
|
225
|
+
* Plays Sound on Event Callback
|
|
226
|
+
* @param name Sound Name
|
|
227
|
+
* @param callback Callback
|
|
228
228
|
|
|
229
229
|
]]
|
|
230
230
|
local function onEnd(sound, callback)
|
|
@@ -235,9 +235,9 @@ local function createSoundRegistry(definitions)
|
|
|
235
235
|
_sound.Ended:Connect(callback)
|
|
236
236
|
end
|
|
237
237
|
--[[
|
|
238
|
-
*
|
|
239
|
-
* Preloads a Sound
|
|
240
|
-
* @param sound Sound Instance
|
|
238
|
+
*
|
|
239
|
+
* Preloads a Sound
|
|
240
|
+
* @param sound Sound Instance
|
|
241
241
|
|
|
242
242
|
]]
|
|
243
243
|
local function preload(sound)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/sound-manager",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A sound manager for Roblox-Typescript projects.",
|
|
5
5
|
"main": "out/init.lua",
|
|
6
6
|
"scripts": {
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"typescript": "^5.9.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@rbxts/sound-manager": "file:rbxts-sound-manager-1.2.0.tgz",
|
|
38
37
|
"@rbxts/testez": "^0.4.2-ts.0"
|
|
39
38
|
}
|
|
40
39
|
}
|