@quenty/sounds 4.0.0-canary.236.5597d0a.0 → 4.1.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 CHANGED
@@ -3,7 +3,66 @@
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.0.0-canary.236.5597d0a.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.4.0...@quenty/sounds@4.0.0-canary.236.5597d0a.0) (2021-12-18)
6
+ # [4.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@4.0.0...@quenty/sounds@4.1.0) (2022-03-10)
7
+
8
+ **Note:** Version bump only for package @quenty/sounds
9
+
10
+
11
+
12
+
13
+
14
+ # [4.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.8.0...@quenty/sounds@4.0.0) (2022-03-06)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * Support sound playback for non-local situations. On the server this will require the sound to be parented. ([1884237](https://github.com/Quenty/NevermoreEngine/commit/1884237120fbbb3c9b29032d995c132af381f16b))
20
+
21
+
22
+
23
+
24
+
25
+ # [3.8.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.7.1...@quenty/sounds@3.8.0) (2022-01-17)
26
+
27
+ **Note:** Version bump only for package @quenty/sounds
28
+
29
+
30
+
31
+
32
+
33
+ ## [3.7.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.7.0...@quenty/sounds@3.7.1) (2022-01-16)
34
+
35
+ **Note:** Version bump only for package @quenty/sounds
36
+
37
+
38
+
39
+
40
+
41
+ # [3.7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.6.0...@quenty/sounds@3.7.0) (2022-01-07)
42
+
43
+ **Note:** Version bump only for package @quenty/sounds
44
+
45
+
46
+
47
+
48
+
49
+ # [3.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.5.1...@quenty/sounds@3.6.0) (2022-01-03)
50
+
51
+ **Note:** Version bump only for package @quenty/sounds
52
+
53
+
54
+
55
+
56
+
57
+ ## [3.5.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.5.0...@quenty/sounds@3.5.1) (2021-12-30)
58
+
59
+ **Note:** Version bump only for package @quenty/sounds
60
+
61
+
62
+
63
+
64
+
65
+ # [3.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.4.0...@quenty/sounds@3.5.0) (2021-12-18)
7
66
 
8
67
  **Note:** Version bump only for package @quenty/sounds
9
68
 
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  ## SoundPromiseUtils
2
2
  <div align="center">
3
- <a href="http://quenty.github.io/api/">
4
- <img src="https://img.shields.io/badge/docs-website-green.svg" alt="Documentation" />
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/badge/discord-nevermore-blue.svg" alt="Discord" />
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": "4.0.0-canary.236.5597d0a.0",
3
+ "version": "4.1.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": "3.1.1",
30
- "@quenty/promise": "4.0.0-canary.236.5597d0a.0"
29
+ "@quenty/loader": "^4.0.0",
30
+ "@quenty/promise": "^4.1.0"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "5597d0abdadd88f369f1401a558a8d6d1a1c5aab"
35
+ "gitHead": "0797de955876b050fb24875de0423453e268b2ce"
36
36
  }
@@ -1,6 +1,7 @@
1
- --- Utility functions involving sounds and their state
2
- -- @module SoundPromiseUtils
3
- -- @author Quenty
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,19 +1,47 @@
1
- --- Helps play sounds on the client
2
- -- @module SoundUtils
3
- -- @author Quenty
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")
12
+ local RunService = game:GetService("RunService")
6
13
 
7
14
  local SoundUtils = {}
8
15
 
9
- function SoundUtils.playTemplate(templates, templateName)
10
- assert(type(templates) == "table", "Bad templates")
11
- assert(type(templateName) == "string", "Bad templateName")
16
+ --[=[
17
+ Plays back a template given asset id.
12
18
 
13
- local sound = templates:Clone(templateName)
19
+ ```lua
20
+ SoundUtils.playFromId("rbxassetid://4255432837") -- Plays a wooshing sound
21
+ ```
22
+
23
+ :::tip
24
+ The sound will be automatically cleaned up after the sound is played.
25
+ :::
26
+
27
+ @param id string | number
28
+ @return Sound
29
+ ]=]
30
+ function SoundUtils.playFromId(id)
31
+ local soundId = SoundUtils.toRbxAssetId(id)
32
+ assert(type(soundId) == "string", "Bad id")
33
+
34
+ local sound = Instance.new("Sound")
35
+ sound.Name = ("Sound_%s"):format(soundId)
36
+ sound.SoundId = soundId
37
+ sound.Volume = 0.25
14
38
  sound.Archivable = false
15
39
 
16
- SoundService:PlayLocalSound(sound)
40
+ if RunService:IsClient() then
41
+ SoundService:PlayLocalSound(sound)
42
+ else
43
+ sound:Play()
44
+ end
17
45
 
18
46
  task.delay(sound.TimeLength + 0.05, function()
19
47
  sound:Destroy()
@@ -22,14 +50,22 @@ function SoundUtils.playTemplate(templates, templateName)
22
50
  return sound
23
51
  end
24
52
 
25
- function SoundUtils.playFromId(id)
26
- local soundId = SoundUtils.toRbxAssetId(id)
27
- assert(type(soundId) == "string", "Bad id")
53
+ --[=[
54
+ Plays back a template given the templateName.
28
55
 
29
- local sound = Instance.new("Sound")
30
- sound.Name = ("Sound_%s"):format(soundId)
31
- sound.SoundId = soundId
32
- sound.Volume = 0.25
56
+ :::tip
57
+ The sound will be automatically cleaned up after the sound is played.
58
+ :::
59
+
60
+ @param templates TemplateProvider
61
+ @param templateName string
62
+ @return Sound
63
+ ]=]
64
+ function SoundUtils.playTemplate(templates, templateName)
65
+ assert(type(templates) == "table", "Bad templates")
66
+ assert(type(templateName) == "string", "Bad templateName")
67
+
68
+ local sound = templates:Clone(templateName)
33
69
  sound.Archivable = false
34
70
 
35
71
  SoundService:PlayLocalSound(sound)
@@ -41,6 +77,11 @@ function SoundUtils.playFromId(id)
41
77
  return sound
42
78
  end
43
79
 
80
+ --[=[
81
+ Converts a string or number to a string for playback.
82
+ @param id string | number
83
+ @return string
84
+ ]=]
44
85
  function SoundUtils.toRbxAssetId(id)
45
86
  if type(id) == "number" then
46
87
  return ("rbxassetid://%d"):format(id)
@@ -49,6 +90,18 @@ function SoundUtils.toRbxAssetId(id)
49
90
  end
50
91
  end
51
92
 
93
+ --[=[
94
+ Plays back a sound template in a specific parent.
95
+
96
+ :::tip
97
+ The sound will be automatically cleaned up after the sound is played.
98
+ :::
99
+
100
+ @param templates TemplateProvider
101
+ @param templateName string
102
+ @param parent Instance
103
+ @return Sound
104
+ ]=]
52
105
  function SoundUtils.playTemplateInParent(templates, templateName, parent)
53
106
  local sound = templates:Clone(templateName)
54
107
  sound.Archivable = false
@@ -63,5 +116,4 @@ function SoundUtils.playTemplateInParent(templates, templateName, parent)
63
116
  return sound
64
117
  end
65
118
 
66
-
67
119
  return SoundUtils