@quenty/sounds 3.3.0 → 3.4.1-canary.8533eea.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,6 +3,25 @@
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.4.1-canary.8533eea.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.4.0...@quenty/sounds@3.4.1-canary.8533eea.0) (2021-12-18)
7
+
8
+ **Note:** Version bump only for package @quenty/sounds
9
+
10
+
11
+
12
+
13
+
14
+ # [3.4.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.3.0...@quenty/sounds@3.4.0) (2021-12-14)
15
+
16
+
17
+ ### Features
18
+
19
+ * Add SoundUtils.playFromId(id) ([71b5c5b](https://github.com/Quenty/NevermoreEngine/commit/71b5c5b007fc4229b9c10adcbb20ad0c87227550))
20
+
21
+
22
+
23
+
24
+
6
25
  # [3.3.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/sounds@3.2.2...@quenty/sounds@3.3.0) (2021-11-20)
7
26
 
8
27
 
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014 Quenty
3
+ Copyright (c) 2014-2021 Quenty
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/sounds",
3
- "version": "3.3.0",
3
+ "version": "3.4.1-canary.8533eea.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": "^3.2.0"
29
+ "@quenty/loader": "3.1.1",
30
+ "@quenty/promise": "3.2.1-canary.8533eea.0"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "87ab1435a59a05e7dd745db1dfcec26116d1d71d"
35
+ "gitHead": "8533eeade3bf6835c0295785c1c326b9abee3222"
36
36
  }
@@ -15,13 +15,40 @@ function SoundUtils.playTemplate(templates, templateName)
15
15
 
16
16
  SoundService:PlayLocalSound(sound)
17
17
 
18
- delay(sound.TimeLength + 0.05, function()
18
+ task.delay(sound.TimeLength + 0.05, function()
19
19
  sound:Destroy()
20
20
  end)
21
21
 
22
22
  return sound
23
23
  end
24
24
 
25
+ function SoundUtils.playFromId(id)
26
+ local soundId = SoundUtils.toRbxAssetId(id)
27
+ assert(type(soundId) == "string", "Bad id")
28
+
29
+ local sound = Instance.new("Sound")
30
+ sound.Name = ("Sound_%s"):format(soundId)
31
+ sound.SoundId = soundId
32
+ sound.Volume = 0.25
33
+ sound.Archivable = false
34
+
35
+ SoundService:PlayLocalSound(sound)
36
+
37
+ task.delay(sound.TimeLength + 0.05, function()
38
+ sound:Destroy()
39
+ end)
40
+
41
+ return sound
42
+ end
43
+
44
+ function SoundUtils.toRbxAssetId(id)
45
+ if type(id) == "number" then
46
+ return ("rbxassetid://%d"):format(id)
47
+ else
48
+ return id
49
+ end
50
+ end
51
+
25
52
  function SoundUtils.playTemplateInParent(templates, templateName, parent)
26
53
  local sound = templates:Clone(templateName)
27
54
  sound.Archivable = false
@@ -29,7 +56,7 @@ function SoundUtils.playTemplateInParent(templates, templateName, parent)
29
56
 
30
57
  sound:Play()
31
58
 
32
- delay(sound.TimeLength + 0.05, function()
59
+ task.delay(sound.TimeLength + 0.05, function()
33
60
  sound:Destroy()
34
61
  end)
35
62