@quenty/valuebaseutils 5.1.0 → 5.2.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 +5 -5
- package/src/Shared/ValueBaseUtils.lua +91 -2
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
|
+
# [5.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@5.1.0...@quenty/valuebaseutils@5.2.0) (2022-07-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add ValueBaseUtils.getValueBaseType(valueBaseClassName) and ValueBaseUtils.getClassNameFromType(luaType) as well as docs ([1e0097d](https://github.com/Quenty/NevermoreEngine/commit/1e0097d22dcdc7051d1bf893c69056807926c301))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [5.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/valuebaseutils@5.0.0...@quenty/valuebaseutils@5.1.0) (2022-06-21)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/valuebaseutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/valuebaseutils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Provides utilities for working with valuesbase objects, like IntValue or ObjectValue in Roblox.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/brio": "^6.
|
|
29
|
-
"@quenty/instanceutils": "^5.
|
|
28
|
+
"@quenty/brio": "^6.2.0",
|
|
29
|
+
"@quenty/instanceutils": "^5.2.0",
|
|
30
30
|
"@quenty/loader": "^5.0.0",
|
|
31
|
-
"@quenty/promise": "^5.
|
|
31
|
+
"@quenty/promise": "^5.1.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "e31b3a35aa475bb5699a24898a8639e107165b36"
|
|
37
37
|
}
|
|
@@ -1,14 +1,76 @@
|
|
|
1
1
|
--[=[
|
|
2
|
-
Provides utilities for working with
|
|
2
|
+
Provides utilities for working with ValueBase objects, like [IntValue] or [ObjectValue] in Roblox.
|
|
3
|
+
|
|
3
4
|
@class ValueBaseUtils
|
|
4
5
|
]=]
|
|
5
6
|
|
|
6
7
|
local ValueBaseUtils = {}
|
|
7
8
|
|
|
9
|
+
local TYPE_TO_CLASSNAME_LOOKUP = {
|
|
10
|
+
["nil"] = "ObjectValue";
|
|
11
|
+
boolean = "BoolValue";
|
|
12
|
+
number = "NumberValue";
|
|
13
|
+
string = "StringValue";
|
|
14
|
+
|
|
15
|
+
BrickColor = "BrickColorValue";
|
|
16
|
+
CFrame = "CFrameValue";
|
|
17
|
+
Color3 = "Color3Value";
|
|
18
|
+
Instance = "ObjectValue";
|
|
19
|
+
Ray = "RayValue";
|
|
20
|
+
Vector3 = "Vector3Value";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
local VALUE_BASE_TYPE_LOOKUP = {
|
|
24
|
+
BoolValue = "boolean";
|
|
25
|
+
NumberValue = "number";
|
|
26
|
+
StringValue = "string";
|
|
27
|
+
BrickColorValue = "BrickColor";
|
|
28
|
+
CFrameValue = "CFrame";
|
|
29
|
+
Color3Value = "Color3";
|
|
30
|
+
ObjectValue = "Instance";
|
|
31
|
+
RayValue = "Ray";
|
|
32
|
+
Vector3Value = "Vector3";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
--[=[
|
|
36
|
+
Returns true if the value is a ValueBase instance
|
|
37
|
+
|
|
38
|
+
@param instance Instance
|
|
39
|
+
@return boolean
|
|
40
|
+
]=]
|
|
8
41
|
function ValueBaseUtils.isValueBase(instance)
|
|
9
|
-
return typeof(instance) == "Instance" and instance
|
|
42
|
+
return typeof(instance) == "Instance" and instance:IsA("ValueBase")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
--[=[
|
|
46
|
+
Gets the lua type for the given class name
|
|
47
|
+
|
|
48
|
+
@param valueBaseClassName string
|
|
49
|
+
@return string?
|
|
50
|
+
]=]
|
|
51
|
+
function ValueBaseUtils.getValueBaseType(valueBaseClassName)
|
|
52
|
+
return VALUE_BASE_TYPE_LOOKUP[valueBaseClassName]
|
|
10
53
|
end
|
|
11
54
|
|
|
55
|
+
--[=[
|
|
56
|
+
Gets class type for the given lua type
|
|
57
|
+
|
|
58
|
+
@param luaType string
|
|
59
|
+
@return string?
|
|
60
|
+
]=]
|
|
61
|
+
function ValueBaseUtils.getClassNameFromType(luaType)
|
|
62
|
+
return TYPE_TO_CLASSNAME_LOOKUP[luaType]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
--[=[
|
|
66
|
+
Initializes the value as needed
|
|
67
|
+
|
|
68
|
+
@param parent Instance
|
|
69
|
+
@param instanceType string
|
|
70
|
+
@param name string
|
|
71
|
+
@param defaultValue any?
|
|
72
|
+
@return Instance
|
|
73
|
+
]=]
|
|
12
74
|
function ValueBaseUtils.getOrCreateValue(parent, instanceType, name, defaultValue)
|
|
13
75
|
assert(typeof(parent) == "Instance", "Bad argument 'parent'")
|
|
14
76
|
assert(type(instanceType) == "string", "Bad argument 'instanceType'")
|
|
@@ -32,6 +94,15 @@ function ValueBaseUtils.getOrCreateValue(parent, instanceType, name, defaultValu
|
|
|
32
94
|
end
|
|
33
95
|
end
|
|
34
96
|
|
|
97
|
+
--[=[
|
|
98
|
+
Sets the value for the parent
|
|
99
|
+
|
|
100
|
+
@param parent Instance
|
|
101
|
+
@param instanceType string
|
|
102
|
+
@param name string
|
|
103
|
+
@param value any
|
|
104
|
+
@return any
|
|
105
|
+
]=]
|
|
35
106
|
function ValueBaseUtils.setValue(parent, instanceType, name, value)
|
|
36
107
|
assert(typeof(parent) == "Instance", "Bad argument 'parent'")
|
|
37
108
|
assert(type(instanceType) == "string", "Bad argument 'instanceType'")
|
|
@@ -53,6 +124,15 @@ function ValueBaseUtils.setValue(parent, instanceType, name, value)
|
|
|
53
124
|
end
|
|
54
125
|
end
|
|
55
126
|
|
|
127
|
+
--[=[
|
|
128
|
+
Gets the value in the children
|
|
129
|
+
|
|
130
|
+
@param parent Instance
|
|
131
|
+
@param instanceType string
|
|
132
|
+
@param name string
|
|
133
|
+
@param default any?
|
|
134
|
+
@return any
|
|
135
|
+
]=]
|
|
56
136
|
function ValueBaseUtils.getValue(parent, instanceType, name, default)
|
|
57
137
|
assert(typeof(parent) == "Instance", "Bad argument 'parent'")
|
|
58
138
|
assert(type(instanceType) == "string", "Bad argument 'instanceType'")
|
|
@@ -72,6 +152,15 @@ function ValueBaseUtils.getValue(parent, instanceType, name, default)
|
|
|
72
152
|
end
|
|
73
153
|
end
|
|
74
154
|
|
|
155
|
+
--[=[
|
|
156
|
+
Gets a getter, setter, and initializer for the instance type and name.
|
|
157
|
+
|
|
158
|
+
@param instanceType string
|
|
159
|
+
@param name string
|
|
160
|
+
@return function
|
|
161
|
+
@return function
|
|
162
|
+
@return function
|
|
163
|
+
]=]
|
|
75
164
|
function ValueBaseUtils.createGetSet(instanceType, name)
|
|
76
165
|
assert(type(instanceType) == "string", "Bad argument 'instanceType'")
|
|
77
166
|
assert(type(name) == "string", "Bad argument 'name'")
|