@quenty/sounds 3.4.1-canary.8533eea.0 → 3.5.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/CHANGELOG.md +9 -1
- package/README.md +6 -12
- package/package.json +4 -4
- package/src/Shared/SoundPromiseUtils.lua +14 -3
- package/src/Shared/SoundUtils.lua +51 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,15 @@
|
|
|
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
|
-
## [3.
|
|
6
|
+
## [3.5.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.5.0...@quenty/sounds@3.5.1) (2021-12-30)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/sounds
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.4.0...@quenty/sounds@3.5.0) (2021-12-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @quenty/sounds
|
|
9
17
|
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
## SoundPromiseUtils
|
|
2
2
|
<div align="center">
|
|
3
|
-
<a href="http://quenty.github.io/
|
|
4
|
-
<img src="https://
|
|
3
|
+
<a href="http://quenty.github.io/NevermoreEngine/">
|
|
4
|
+
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/docs.yml/badge.svg" alt="Documentation status" />
|
|
5
5
|
</a>
|
|
6
6
|
<a href="https://discord.gg/mhtGUS8">
|
|
7
|
-
<img src="https://img.shields.io/
|
|
7
|
+
<img src="https://img.shields.io/discord/385151591524597761?color=5865F2&label=discord&logo=discord&logoColor=white" alt="Discord" />
|
|
8
8
|
</a>
|
|
9
9
|
<a href="https://github.com/Quenty/NevermoreEngine/actions">
|
|
10
10
|
<img src="https://github.com/Quenty/NevermoreEngine/actions/workflows/build.yml/badge.svg" alt="Build and release status" />
|
|
@@ -13,15 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
Utility functions involving sounds and their state
|
|
15
15
|
|
|
16
|
+
<div align="center"><a href="https://quenty.github.io/NevermoreEngine/api/SoundUtils">View docs →</a></div>
|
|
17
|
+
|
|
16
18
|
## Installation
|
|
17
19
|
```
|
|
18
20
|
npm install @quenty/soundpromiseutils --save
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
Usage is designed to be simple.
|
|
23
|
-
|
|
24
|
-
### `SoundPromiseUtils.promiseLoaded(sound)`
|
|
25
|
-
|
|
26
|
-
### `SoundPromiseUtils.promiseAllSoundsLoaded(sounds)`
|
|
27
|
-
|
|
21
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/sounds",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.1",
|
|
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": "3.1.
|
|
30
|
-
"@quenty/promise": "3.
|
|
29
|
+
"@quenty/loader": "^3.1.2",
|
|
30
|
+
"@quenty/promise": "^3.3.1"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "d146c77d0a8e452824de0ab0b4b03ba0370bcc1b"
|
|
36
36
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
--[=[
|
|
2
|
+
Utility functions involving sounds and their state
|
|
3
|
+
@class SoundPromiseUtils
|
|
4
|
+
]=]
|
|
4
5
|
|
|
5
6
|
local require = require(script.Parent.loader).load(script)
|
|
6
7
|
|
|
@@ -9,6 +10,11 @@ local PromiseUtils = require("PromiseUtils")
|
|
|
9
10
|
|
|
10
11
|
local SoundPromiseUtils = {}
|
|
11
12
|
|
|
13
|
+
--[=[
|
|
14
|
+
Promises that a sound is loaded
|
|
15
|
+
@param sound Sound
|
|
16
|
+
@return Promise
|
|
17
|
+
]=]
|
|
12
18
|
function SoundPromiseUtils.promiseLoaded(sound)
|
|
13
19
|
if sound.IsLoaded then
|
|
14
20
|
return Promise.resolved()
|
|
@@ -31,6 +37,11 @@ function SoundPromiseUtils.promiseLoaded(sound)
|
|
|
31
37
|
return promise
|
|
32
38
|
end
|
|
33
39
|
|
|
40
|
+
--[=[
|
|
41
|
+
Promises that all sounds are loaded
|
|
42
|
+
@param sounds { Sound }
|
|
43
|
+
@return Promise
|
|
44
|
+
]=]
|
|
34
45
|
function SoundPromiseUtils.promiseAllSoundsLoaded(sounds)
|
|
35
46
|
local promises = {}
|
|
36
47
|
for _, sound in pairs(sounds) do
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
--[=[
|
|
2
|
+
Helps plays back sounds in the Roblox engine.
|
|
3
|
+
|
|
4
|
+
```lua
|
|
5
|
+
SoundUtils.playFromId("rbxassetid://4255432837") -- Plays a wooshing sound
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
@class SoundUtils
|
|
9
|
+
]=]
|
|
4
10
|
|
|
5
11
|
local SoundService = game:GetService("SoundService")
|
|
6
12
|
|
|
7
13
|
local SoundUtils = {}
|
|
8
14
|
|
|
15
|
+
--[=[
|
|
16
|
+
Plays back a template given the templateName.
|
|
17
|
+
|
|
18
|
+
:::tip
|
|
19
|
+
The sound will be automatically cleaned up after the sound is played.
|
|
20
|
+
:::
|
|
21
|
+
|
|
22
|
+
@param templates TemplateProvider
|
|
23
|
+
@param templateName string
|
|
24
|
+
@return Sound
|
|
25
|
+
]=]
|
|
9
26
|
function SoundUtils.playTemplate(templates, templateName)
|
|
10
27
|
assert(type(templates) == "table", "Bad templates")
|
|
11
28
|
assert(type(templateName) == "string", "Bad templateName")
|
|
@@ -22,6 +39,20 @@ function SoundUtils.playTemplate(templates, templateName)
|
|
|
22
39
|
return sound
|
|
23
40
|
end
|
|
24
41
|
|
|
42
|
+
--[=[
|
|
43
|
+
Plays back a template given asset id.
|
|
44
|
+
|
|
45
|
+
```lua
|
|
46
|
+
SoundUtils.playFromId("rbxassetid://4255432837") -- Plays a wooshing sound
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
:::tip
|
|
50
|
+
The sound will be automatically cleaned up after the sound is played.
|
|
51
|
+
:::
|
|
52
|
+
|
|
53
|
+
@param id string | number
|
|
54
|
+
@return Sound
|
|
55
|
+
]=]
|
|
25
56
|
function SoundUtils.playFromId(id)
|
|
26
57
|
local soundId = SoundUtils.toRbxAssetId(id)
|
|
27
58
|
assert(type(soundId) == "string", "Bad id")
|
|
@@ -41,6 +72,11 @@ function SoundUtils.playFromId(id)
|
|
|
41
72
|
return sound
|
|
42
73
|
end
|
|
43
74
|
|
|
75
|
+
--[=[
|
|
76
|
+
Converts a string or number to a string for playback.
|
|
77
|
+
@param id string | number
|
|
78
|
+
@return string
|
|
79
|
+
]=]
|
|
44
80
|
function SoundUtils.toRbxAssetId(id)
|
|
45
81
|
if type(id) == "number" then
|
|
46
82
|
return ("rbxassetid://%d"):format(id)
|
|
@@ -49,6 +85,18 @@ function SoundUtils.toRbxAssetId(id)
|
|
|
49
85
|
end
|
|
50
86
|
end
|
|
51
87
|
|
|
88
|
+
--[=[
|
|
89
|
+
Plays back a sound template in a specific parent.
|
|
90
|
+
|
|
91
|
+
:::tip
|
|
92
|
+
The sound will be automatically cleaned up after the sound is played.
|
|
93
|
+
:::
|
|
94
|
+
|
|
95
|
+
@param templates TemplateProvider
|
|
96
|
+
@param templateName string
|
|
97
|
+
@param parent Instance
|
|
98
|
+
@return Sound
|
|
99
|
+
]=]
|
|
52
100
|
function SoundUtils.playTemplateInParent(templates, templateName, parent)
|
|
53
101
|
local sound = templates:Clone(templateName)
|
|
54
102
|
sound.Archivable = false
|
|
@@ -63,5 +111,4 @@ function SoundUtils.playTemplateInParent(templates, templateName, parent)
|
|
|
63
111
|
return sound
|
|
64
112
|
end
|
|
65
113
|
|
|
66
|
-
|
|
67
114
|
return SoundUtils
|