@quenty/sounds 4.2.0 → 4.2.1-canary.256.8cd6f5a.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 +12 -0
- package/package.json +4 -4
- package/src/Shared/SoundUtils.lua +21 -20
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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
|
+
## [4.2.1-canary.256.8cd6f5a.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@4.2.0...@quenty/sounds@4.2.1-canary.256.8cd6f5a.0) (2022-03-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* Add initial package-locks to packages without them ([4ff9578](https://github.com/Quenty/NevermoreEngine/commit/4ff9578522d02d38d71a1c58d865a203a1c214f5))
|
|
12
|
+
* Sounds can be played back from parents, and we can create sounds without playing them ([49e8863](https://github.com/Quenty/NevermoreEngine/commit/49e8863450ff5fc23333ae23a8c25bc93954ecbd))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
# [4.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@4.1.0...@quenty/sounds@4.2.0) (2022-03-20)
|
|
7
19
|
|
|
8
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/sounds",
|
|
3
|
-
"version": "4.2.0",
|
|
3
|
+
"version": "4.2.1-canary.256.8cd6f5a.0",
|
|
4
4
|
"description": "Utility functions involving sounds and their state",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"Quenty"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/loader": "
|
|
30
|
-
"@quenty/promise": "
|
|
29
|
+
"@quenty/loader": "4.0.1-canary.256.8cd6f5a.0",
|
|
30
|
+
"@quenty/promise": "4.1.1-canary.256.8cd6f5a.0"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "8cd6f5a870e3e400eb53d147873062111e6ae8ed"
|
|
36
36
|
}
|
|
@@ -31,15 +31,11 @@ local SoundUtils = {}
|
|
|
31
31
|
@param id string | number
|
|
32
32
|
@return Sound
|
|
33
33
|
]=]
|
|
34
|
-
function SoundUtils.playFromId(id)
|
|
34
|
+
function SoundUtils.playFromId(id: string | number): Sound
|
|
35
35
|
local soundId = SoundUtils.toRbxAssetId(id)
|
|
36
36
|
assert(type(soundId) == "string", "Bad id")
|
|
37
37
|
|
|
38
|
-
local sound =
|
|
39
|
-
sound.Name = ("Sound_%s"):format(soundId)
|
|
40
|
-
sound.SoundId = soundId
|
|
41
|
-
sound.Volume = 0.25
|
|
42
|
-
sound.Archivable = false
|
|
38
|
+
local sound = SoundUtils.createSoundFromId(id)
|
|
43
39
|
|
|
44
40
|
if RunService:IsClient() then
|
|
45
41
|
SoundService:PlayLocalSound(sound)
|
|
@@ -53,15 +49,9 @@ function SoundUtils.playFromId(id)
|
|
|
53
49
|
end
|
|
54
50
|
|
|
55
51
|
--[=[
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
@param id string | number
|
|
59
|
-
@param parent Instance
|
|
60
|
-
@return Sound
|
|
52
|
+
Creates a new sound object from the given id
|
|
61
53
|
]=]
|
|
62
|
-
function SoundUtils.
|
|
63
|
-
assert(typeof(parent) == "Instance", "Bad parent")
|
|
64
|
-
|
|
54
|
+
function SoundUtils.createSoundFromId(id: string | number): Sound
|
|
65
55
|
local soundId = SoundUtils.toRbxAssetId(id)
|
|
66
56
|
assert(type(soundId) == "string", "Bad id")
|
|
67
57
|
|
|
@@ -70,6 +60,17 @@ function SoundUtils.playFromIdInParent(id, parent)
|
|
|
70
60
|
sound.SoundId = soundId
|
|
71
61
|
sound.Volume = 0.25
|
|
72
62
|
sound.Archivable = false
|
|
63
|
+
|
|
64
|
+
return sound
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
--[=[
|
|
68
|
+
Plays back a template given asset id in the parent
|
|
69
|
+
]=]
|
|
70
|
+
function SoundUtils.playFromIdInParent(id: string | number, parent: Instance): Sound
|
|
71
|
+
assert(typeof(parent) == "Instance", "Bad parent")
|
|
72
|
+
|
|
73
|
+
local sound = SoundUtils.createSoundFromId(id)
|
|
73
74
|
sound.Parent = parent
|
|
74
75
|
|
|
75
76
|
if not RunService:IsRunning() then
|
|
@@ -88,7 +89,7 @@ end
|
|
|
88
89
|
|
|
89
90
|
@param sound Sound
|
|
90
91
|
]=]
|
|
91
|
-
function SoundUtils.removeAfterTimeLength(sound)
|
|
92
|
+
function SoundUtils.removeAfterTimeLength(sound: Sound)
|
|
92
93
|
-- TODO: clean up on destroying
|
|
93
94
|
SoundPromiseUtils.promiseLoaded(sound):Then(function()
|
|
94
95
|
task.delay(sound.TimeLength + 0.05, function()
|
|
@@ -110,7 +111,7 @@ end
|
|
|
110
111
|
@param templateName string
|
|
111
112
|
@return Sound
|
|
112
113
|
]=]
|
|
113
|
-
function SoundUtils.playTemplate(templates, templateName)
|
|
114
|
+
function SoundUtils.playTemplate(templates, templateName: string)
|
|
114
115
|
assert(type(templates) == "table", "Bad templates")
|
|
115
116
|
assert(type(templateName) == "string", "Bad templateName")
|
|
116
117
|
|
|
@@ -126,10 +127,10 @@ end
|
|
|
126
127
|
|
|
127
128
|
--[=[
|
|
128
129
|
Converts a string or number to a string for playback.
|
|
129
|
-
@param id string | number
|
|
130
|
-
@return string
|
|
130
|
+
@param id string? | number
|
|
131
|
+
@return string?
|
|
131
132
|
]=]
|
|
132
|
-
function SoundUtils.toRbxAssetId(id)
|
|
133
|
+
function SoundUtils.toRbxAssetId(id: string? | number): string
|
|
133
134
|
if type(id) == "number" then
|
|
134
135
|
return ("rbxassetid://%d"):format(id)
|
|
135
136
|
else
|
|
@@ -149,7 +150,7 @@ end
|
|
|
149
150
|
@param parent Instance
|
|
150
151
|
@return Sound
|
|
151
152
|
]=]
|
|
152
|
-
function SoundUtils.playTemplateInParent(templates, templateName, parent)
|
|
153
|
+
function SoundUtils.playTemplateInParent(templates, templateName: string, parent: Instance)
|
|
153
154
|
local sound = templates:Clone(templateName)
|
|
154
155
|
sound.Archivable = false
|
|
155
156
|
sound.Parent = parent
|