@rbxts/sound-manager 1.0.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/README.md +17 -0
- package/out/core/options.d.ts +4 -0
- package/out/core/options.luau +2 -0
- package/out/index.d.ts +7 -0
- package/out/init.luau +55 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Sound Manager
|
|
2
|
+
|
|
3
|
+
A Roblox sound management library built with Roblox-TS
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
To use the Sound Manager library in your Roblox-TS project install it via npm:
|
|
7
|
+
```bash
|
|
8
|
+
npm install @rbxts/sound-manager
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Example usage:
|
|
12
|
+
```typescript
|
|
13
|
+
import { Sounds } from "@rbxts/sound-manager";
|
|
14
|
+
|
|
15
|
+
Sounds.load("TestSound", "rbxassetid://4714389545", { volume: 1, loop: false });
|
|
16
|
+
Sounds.play("TestSound")
|
|
17
|
+
```
|
package/out/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SoundOptions } from "./core/options";
|
|
2
|
+
export declare namespace Sounds {
|
|
3
|
+
/** * * @param sound Define the Sound to play */
|
|
4
|
+
function play(soundName: string): void;
|
|
5
|
+
/** * * @param soundname Define the name of the Sound * @param soundid Define the SoundID of the Sound * @param options Define the options for the Sound (e.g. volume) */
|
|
6
|
+
function load(soundName: string, soundId: string, options?: SoundOptions): void;
|
|
7
|
+
}
|
package/out/init.luau
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local Sounds = {}
|
|
3
|
+
do
|
|
4
|
+
local _container = Sounds
|
|
5
|
+
--* * * @param sound Define the Sound to play
|
|
6
|
+
local function play(soundName)
|
|
7
|
+
local soundFolder = game:GetService("ReplicatedStorage"):FindFirstChild("Sounds")
|
|
8
|
+
if not soundFolder then
|
|
9
|
+
warn("Sound folder not found in ReplicatedStorage.")
|
|
10
|
+
return nil
|
|
11
|
+
end
|
|
12
|
+
local _sound = soundFolder:FindFirstChild(soundName)
|
|
13
|
+
if _sound then
|
|
14
|
+
_sound:Play()
|
|
15
|
+
else
|
|
16
|
+
warn(`Sound: {soundName} not found! Make sure to load it first.`)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
_container.play = play
|
|
20
|
+
--* * * @param soundname Define the name of the Sound * @param soundid Define the SoundID of the Sound * @param options Define the options for the Sound (e.g. volume)
|
|
21
|
+
local function load(soundName, soundId, options)
|
|
22
|
+
local soundFolder = game:GetService("ReplicatedStorage"):FindFirstChild("Sounds")
|
|
23
|
+
if not soundFolder then
|
|
24
|
+
soundFolder = Instance.new("Folder")
|
|
25
|
+
soundFolder.Name = "Sounds"
|
|
26
|
+
soundFolder.Parent = game:GetService("ReplicatedStorage")
|
|
27
|
+
end
|
|
28
|
+
if soundFolder:FindFirstChild(soundName) then
|
|
29
|
+
warn(`Sound: {soundName} already exists.`)
|
|
30
|
+
return nil
|
|
31
|
+
end
|
|
32
|
+
local newSound = Instance.new("Sound")
|
|
33
|
+
newSound.Name = soundName
|
|
34
|
+
newSound.SoundId = soundId
|
|
35
|
+
newSound.Parent = soundFolder
|
|
36
|
+
local _result = options
|
|
37
|
+
if _result ~= nil then
|
|
38
|
+
_result = _result.volume
|
|
39
|
+
end
|
|
40
|
+
if _result ~= nil then
|
|
41
|
+
newSound.Volume = options.volume
|
|
42
|
+
end
|
|
43
|
+
local _result_1 = options
|
|
44
|
+
if _result_1 ~= nil then
|
|
45
|
+
_result_1 = _result_1.loop
|
|
46
|
+
end
|
|
47
|
+
if _result_1 ~= nil then
|
|
48
|
+
newSound.Looped = options.loop
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
_container.load = load
|
|
52
|
+
end
|
|
53
|
+
return {
|
|
54
|
+
Sounds = Sounds,
|
|
55
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rbxts/sound-manager",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A sound manager for Roblox-Typescript projects.",
|
|
5
|
+
"main": "out/init.lua",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "rbxtsc",
|
|
8
|
+
"watch": "rbxtsc -w",
|
|
9
|
+
"prepublishOnly": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "Easy-Build-Studio",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"type": "commonjs",
|
|
15
|
+
"types": "out/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"out",
|
|
18
|
+
"!**/*.tsbuildinfo"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@rbxts/compiler-types": "^3.0.0-types.0",
|
|
25
|
+
"@rbxts/types": "^1.0.896",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^8.49.0",
|
|
27
|
+
"@typescript-eslint/parser": "^8.49.0",
|
|
28
|
+
"eslint": "^9.39.2",
|
|
29
|
+
"eslint-config-prettier": "^10.1.8",
|
|
30
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
31
|
+
"eslint-plugin-roblox-ts": "^1.3.1",
|
|
32
|
+
"prettier": "^3.7.4",
|
|
33
|
+
"roblox-ts": "^3.0.0",
|
|
34
|
+
"typescript": "^5.9.3"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@rbxts/testez": "^0.4.2-ts.0"
|
|
38
|
+
}
|
|
39
|
+
}
|