@quenty/playerutils 3.5.0 → 3.5.1-canary.439.4c654fa.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 +11 -0
- package/package.json +8 -7
- package/src/Shared/PlayerUtils.lua +49 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.5.1-canary.439.4c654fa.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playerutils@3.5.0...@quenty/playerutils@3.5.1-canary.439.4c654fa.0) (2024-02-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add PlayerUtils.promiseLoadCharacter(player) and other helper methods ([3ba616b](https://github.com/Quenty/NevermoreEngine/commit/3ba616b45121877b2d841ad218b46091b94a3d8e))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [3.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/playerutils@3.4.0...@quenty/playerutils@3.5.0) (2024-01-08)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/playerutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/playerutils",
|
|
3
|
-
"version": "3.5.0",
|
|
3
|
+
"version": "3.5.1-canary.439.4c654fa.0",
|
|
4
4
|
"description": "Player utility functions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/brio": "
|
|
32
|
-
"@quenty/instanceutils": "
|
|
33
|
-
"@quenty/loader": "
|
|
34
|
-
"@quenty/maid": "
|
|
35
|
-
"@quenty/
|
|
31
|
+
"@quenty/brio": "9.4.1-canary.439.4c654fa.0",
|
|
32
|
+
"@quenty/instanceutils": "8.4.1-canary.439.4c654fa.0",
|
|
33
|
+
"@quenty/loader": "7.3.1-canary.439.4c654fa.0",
|
|
34
|
+
"@quenty/maid": "2.6.1-canary.439.4c654fa.0",
|
|
35
|
+
"@quenty/promise": "7.2.1-canary.439.4c654fa.0",
|
|
36
|
+
"@quenty/rx": "8.4.1-canary.439.4c654fa.0"
|
|
36
37
|
},
|
|
37
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "4c654faf9c66c5c9bcb277a24bf13c70719d3531"
|
|
38
39
|
}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
@class PlayerUtils
|
|
3
3
|
]=]
|
|
4
4
|
|
|
5
|
+
local require = require(script.Parent.loader).load(script)
|
|
6
|
+
|
|
7
|
+
local Promise = require("Promise")
|
|
8
|
+
|
|
5
9
|
local PlayerUtils = {}
|
|
6
10
|
|
|
7
11
|
--[=[
|
|
@@ -83,4 +87,48 @@ function PlayerUtils.getDefaultNameColor(displayName)
|
|
|
83
87
|
return NAME_COLORS[(hashName(displayName) % #NAME_COLORS) + 1]
|
|
84
88
|
end
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
--[=[
|
|
91
|
+
Calls :LoadCharacter() in a promise
|
|
92
|
+
|
|
93
|
+
@param player Player
|
|
94
|
+
@return Promise<Model>
|
|
95
|
+
]=]
|
|
96
|
+
function PlayerUtils.promiseLoadCharacter(player)
|
|
97
|
+
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
98
|
+
|
|
99
|
+
return Promise.spawn(function(resolve, reject)
|
|
100
|
+
local ok, err = pcall(function()
|
|
101
|
+
player:LoadCharacter()
|
|
102
|
+
end)
|
|
103
|
+
if not ok then
|
|
104
|
+
return reject(err or "Failed to load character")
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
return resolve()
|
|
108
|
+
end)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
--[=[
|
|
112
|
+
Calls :LoadCharacterWithHumanoidDescription() in a promise
|
|
113
|
+
|
|
114
|
+
@param player Player
|
|
115
|
+
@param humanoidDescription HumanoidDescription
|
|
116
|
+
@return Promise<Model>
|
|
117
|
+
]=]
|
|
118
|
+
function PlayerUtils.promiseLoadCharacterWithHumanoidDescription(player, humanoidDescription)
|
|
119
|
+
assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
|
|
120
|
+
assert(typeof(humanoidDescription) == "Instance" and humanoidDescription:IsA("HumanoidDescription"), "Bad humanoidDescription")
|
|
121
|
+
|
|
122
|
+
return Promise.spawn(function(resolve, reject)
|
|
123
|
+
local ok, err = pcall(function()
|
|
124
|
+
player:LoadCharacterWithHumanoidDescription(humanoidDescription)
|
|
125
|
+
end)
|
|
126
|
+
if not ok then
|
|
127
|
+
return reject(err or "Failed to load character")
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
return resolve()
|
|
131
|
+
end)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
return PlayerUtils
|