@quenty/sounds 10.10.1 → 10.10.2-canary.545.2374fb2.0
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/CHANGELOG.md +11 -0
- package/package.json +7 -7
- package/src/Shared/SoundPromiseUtils.lua +7 -6
- package/src/Shared/SoundUtils.lua +18 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.10.2-canary.545.2374fb2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@10.10.1...@quenty/sounds@10.10.2-canary.545.2374fb2.0) (2025-04-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [10.10.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@10.10.0...@quenty/sounds@10.10.1) (2025-03-21)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/sounds
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/sounds",
|
|
3
|
-
"version": "10.10.
|
|
3
|
+
"version": "10.10.2-canary.545.2374fb2.0",
|
|
4
4
|
"description": "Utility functions involving sounds and their state",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/loader": "
|
|
30
|
-
"@quenty/maid": "
|
|
31
|
-
"@quenty/promise": "
|
|
32
|
-
"@quenty/promisemaid": "
|
|
33
|
-
"@quenty/rbxasset": "
|
|
29
|
+
"@quenty/loader": "10.8.1-canary.545.2374fb2.0",
|
|
30
|
+
"@quenty/maid": "3.4.1-canary.545.2374fb2.0",
|
|
31
|
+
"@quenty/promise": "10.10.2-canary.545.2374fb2.0",
|
|
32
|
+
"@quenty/promisemaid": "5.10.2-canary.545.2374fb2.0",
|
|
33
|
+
"@quenty/rbxasset": "5.8.1-canary.545.2374fb2.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "2374fb2b043cfbe0e9b507b3316eec46a4e353a0"
|
|
39
39
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
--!strict
|
|
1
2
|
--[=[
|
|
2
3
|
Utility functions involving sounds and their state
|
|
3
4
|
@class SoundPromiseUtils
|
|
@@ -17,7 +18,7 @@ local SoundPromiseUtils = {}
|
|
|
17
18
|
@param sound Sound
|
|
18
19
|
@return Promise
|
|
19
20
|
]=]
|
|
20
|
-
function SoundPromiseUtils.promiseLoaded(sound)
|
|
21
|
+
function SoundPromiseUtils.promiseLoaded(sound: Sound): Promise.Promise<()>
|
|
21
22
|
if sound.IsLoaded then
|
|
22
23
|
return Promise.resolved()
|
|
23
24
|
end
|
|
@@ -44,13 +45,13 @@ function SoundPromiseUtils.promiseLoaded(sound)
|
|
|
44
45
|
return promise
|
|
45
46
|
end
|
|
46
47
|
|
|
47
|
-
function SoundPromiseUtils.promisePlayed(sound)
|
|
48
|
+
function SoundPromiseUtils.promisePlayed(sound: Sound): Promise.Promise<()>
|
|
48
49
|
return SoundPromiseUtils.promiseLoaded(sound):Then(function()
|
|
49
50
|
return PromiseUtils.delayed(sound.TimeLength)
|
|
50
51
|
end)
|
|
51
52
|
end
|
|
52
53
|
|
|
53
|
-
function SoundPromiseUtils.promiseLooped(sound)
|
|
54
|
+
function SoundPromiseUtils.promiseLooped(sound: Sound): Promise.Promise<()>
|
|
54
55
|
local promise = Promise.new()
|
|
55
56
|
|
|
56
57
|
PromiseMaidUtils.whilePromise(promise, function(maid)
|
|
@@ -66,12 +67,12 @@ end
|
|
|
66
67
|
@param sounds { Sound }
|
|
67
68
|
@return Promise
|
|
68
69
|
]=]
|
|
69
|
-
function SoundPromiseUtils.promiseAllSoundsLoaded(sounds)
|
|
70
|
+
function SoundPromiseUtils.promiseAllSoundsLoaded(sounds: { Sound }): Promise.Promise<()>
|
|
70
71
|
local promises = {}
|
|
71
|
-
for _, sound in
|
|
72
|
+
for _, sound in sounds do
|
|
72
73
|
table.insert(promises, SoundPromiseUtils.promiseLoaded(sound))
|
|
73
74
|
end
|
|
74
75
|
return PromiseUtils.all(promises)
|
|
75
76
|
end
|
|
76
77
|
|
|
77
|
-
return SoundPromiseUtils
|
|
78
|
+
return SoundPromiseUtils
|
|
@@ -16,6 +16,10 @@ local RunService = game:GetService("RunService")
|
|
|
16
16
|
local SoundPromiseUtils = require("SoundPromiseUtils")
|
|
17
17
|
local RbxAssetUtils = require("RbxAssetUtils")
|
|
18
18
|
|
|
19
|
+
export type SoundOptions = {
|
|
20
|
+
SoundId: number | string,
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
local SoundUtils = {}
|
|
20
24
|
|
|
21
25
|
--[=[
|
|
@@ -31,7 +35,7 @@ local SoundUtils = {}
|
|
|
31
35
|
|
|
32
36
|
@return Sound
|
|
33
37
|
]=]
|
|
34
|
-
function SoundUtils.playFromId(id: string | number |
|
|
38
|
+
function SoundUtils.playFromId(id: string | number | SoundOptions): Sound
|
|
35
39
|
local sound = SoundUtils.createSoundFromId(id)
|
|
36
40
|
|
|
37
41
|
if RunService:IsClient() then
|
|
@@ -48,7 +52,7 @@ end
|
|
|
48
52
|
--[=[
|
|
49
53
|
Creates a new sound object from the given id
|
|
50
54
|
]=]
|
|
51
|
-
function SoundUtils.createSoundFromId(id: string | number |
|
|
55
|
+
function SoundUtils.createSoundFromId(id: string | number | SoundOptions): Sound
|
|
52
56
|
local soundId = SoundUtils.toRbxAssetId(id)
|
|
53
57
|
assert(type(soundId) == "string", "Bad id")
|
|
54
58
|
|
|
@@ -60,7 +64,7 @@ function SoundUtils.createSoundFromId(id: string | number | table): Sound
|
|
|
60
64
|
return sound
|
|
61
65
|
end
|
|
62
66
|
|
|
63
|
-
function SoundUtils.applyPropertiesFromId(sound, id)
|
|
67
|
+
function SoundUtils.applyPropertiesFromId(sound: Sound, id: string | number | SoundOptions)
|
|
64
68
|
local soundId = SoundUtils.toRbxAssetId(id)
|
|
65
69
|
sound.Name = string.format("Sound_%s", soundId)
|
|
66
70
|
sound.SoundId = soundId
|
|
@@ -68,18 +72,20 @@ function SoundUtils.applyPropertiesFromId(sound, id)
|
|
|
68
72
|
sound.Volume = 0.25
|
|
69
73
|
|
|
70
74
|
if type(id) == "table" then
|
|
71
|
-
|
|
75
|
+
local properties = id :: any
|
|
76
|
+
|
|
77
|
+
for property, value in properties do
|
|
72
78
|
if property ~= "Parent" and property ~= "RollOffMinDistance" then
|
|
73
|
-
sound[property] = value
|
|
79
|
+
(sound :: any)[property] = value
|
|
74
80
|
end
|
|
75
81
|
end
|
|
76
82
|
|
|
77
|
-
if
|
|
78
|
-
sound.RollOffMinDistance =
|
|
83
|
+
if properties.RollOffMinDistance then
|
|
84
|
+
sound.RollOffMinDistance = properties.RollOffMinDistance
|
|
79
85
|
end
|
|
80
86
|
|
|
81
|
-
if
|
|
82
|
-
sound.Parent =
|
|
87
|
+
if properties.Parent then
|
|
88
|
+
sound.Parent = properties.Parent
|
|
83
89
|
end
|
|
84
90
|
end
|
|
85
91
|
end
|
|
@@ -87,7 +93,7 @@ end
|
|
|
87
93
|
--[=[
|
|
88
94
|
Plays back a template given asset id in the parent
|
|
89
95
|
]=]
|
|
90
|
-
function SoundUtils.playFromIdInParent(id: string | number |
|
|
96
|
+
function SoundUtils.playFromIdInParent(id: string | number | SoundOptions, parent: Instance): Sound
|
|
91
97
|
assert(typeof(parent) == "Instance", "Bad parent")
|
|
92
98
|
|
|
93
99
|
local sound = SoundUtils.createSoundFromId(id)
|
|
@@ -149,7 +155,7 @@ end
|
|
|
149
155
|
@return string?
|
|
150
156
|
@within SoundUtils
|
|
151
157
|
]=]
|
|
152
|
-
function SoundUtils.toRbxAssetId(soundId)
|
|
158
|
+
function SoundUtils.toRbxAssetId(soundId: string | number | SoundOptions)
|
|
153
159
|
if type(soundId) == "table" then
|
|
154
160
|
return RbxAssetUtils.toRbxAssetId(soundId.SoundId)
|
|
155
161
|
else
|
|
@@ -157,7 +163,7 @@ function SoundUtils.toRbxAssetId(soundId)
|
|
|
157
163
|
end
|
|
158
164
|
end
|
|
159
165
|
|
|
160
|
-
function SoundUtils.isConvertableToRbxAsset(soundId)
|
|
166
|
+
function SoundUtils.isConvertableToRbxAsset(soundId: string | number | SoundOptions): boolean
|
|
161
167
|
if type(soundId) == "table" then
|
|
162
168
|
return RbxAssetUtils.isConvertableToRbxAsset(soundId.SoundId)
|
|
163
169
|
else
|