@quenty/linkutils 7.5.0 → 7.6.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 +7 -7
- package/src/Shared/LinkUtils.lua +46 -0
- package/src/Shared/RxLinkUtils.lua +7 -0
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
|
+
# [7.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/linkutils@7.5.0...@quenty/linkutils@7.6.0) (2023-02-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add LinkUtils.setSingleLinkValue ([325fcea](https://github.com/Quenty/NevermoreEngine/commit/325fceab423d57ab89e1c4ffbd549adba3bb6127))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [7.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/linkutils@7.4.0...@quenty/linkutils@7.5.0) (2023-01-11)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/linkutils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/linkutils",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0",
|
|
4
4
|
"description": "Utility functions for links. Links are object values pointing to other values!",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@quenty/brio": "^8.
|
|
29
|
-
"@quenty/instanceutils": "^7.
|
|
30
|
-
"@quenty/loader": "^6.0
|
|
28
|
+
"@quenty/brio": "^8.5.0",
|
|
29
|
+
"@quenty/instanceutils": "^7.6.0",
|
|
30
|
+
"@quenty/loader": "^6.1.0",
|
|
31
31
|
"@quenty/maid": "^2.4.0",
|
|
32
|
-
"@quenty/promise": "^6.0
|
|
33
|
-
"@quenty/rx": "^7.
|
|
32
|
+
"@quenty/promise": "^6.1.0",
|
|
33
|
+
"@quenty/rx": "^7.5.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "e084b0cc097ddbcb7c782b8ecbd9c2d619c49354"
|
|
39
39
|
}
|
package/src/Shared/LinkUtils.lua
CHANGED
|
@@ -25,6 +25,7 @@ function LinkUtils.createLink(linkName, from, to)
|
|
|
25
25
|
local objectValue = Instance.new("ObjectValue")
|
|
26
26
|
objectValue.Name = linkName
|
|
27
27
|
objectValue.Value = to
|
|
28
|
+
objectValue.Archivable = false
|
|
28
29
|
objectValue.Parent = from
|
|
29
30
|
|
|
30
31
|
return objectValue
|
|
@@ -54,6 +55,51 @@ function LinkUtils.getAllLinkValues(linkName, from)
|
|
|
54
55
|
return linkValues
|
|
55
56
|
end
|
|
56
57
|
|
|
58
|
+
|
|
59
|
+
--[=[
|
|
60
|
+
Ensures after operation a single link is pointed to the value, unless the value is "nil"
|
|
61
|
+
in which case no link will be set
|
|
62
|
+
|
|
63
|
+
@param linkName string
|
|
64
|
+
@param from Instance
|
|
65
|
+
@param to Instance
|
|
66
|
+
@return Instance | nil
|
|
67
|
+
]=]
|
|
68
|
+
function LinkUtils.setSingleLinkValue(linkName, from, to)
|
|
69
|
+
assert(type(linkName) == "string", "Bad linkName")
|
|
70
|
+
assert(typeof(from) == "Instance", "Bad from")
|
|
71
|
+
assert(typeof(to) == "Instance" or to == nil, "Bad to")
|
|
72
|
+
|
|
73
|
+
if to then
|
|
74
|
+
local existingLink = nil
|
|
75
|
+
for _, link in pairs(from:GetChildren()) do
|
|
76
|
+
if link:IsA("ObjectValue") and link.Name == linkName then
|
|
77
|
+
if existingLink then
|
|
78
|
+
link:Destroy()
|
|
79
|
+
else
|
|
80
|
+
existingLink = link
|
|
81
|
+
link.Value = to
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if existingLink then
|
|
87
|
+
return existingLink
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
return LinkUtils.createLink(linkName, from, to)
|
|
91
|
+
else
|
|
92
|
+
for _, link in pairs(from:GetChildren()) do
|
|
93
|
+
if link:IsA("ObjectValue") and link.Name == linkName then
|
|
94
|
+
link:Destroy()
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
return nil
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
|
|
57
103
|
--[=[
|
|
58
104
|
Gets all links underneath an instance.
|
|
59
105
|
@param linkName string
|
|
@@ -31,6 +31,13 @@ function RxLinkUtils.observeValidLinksBrio(linkName, parent)
|
|
|
31
31
|
})
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
--[=[
|
|
35
|
+
Observes a link value that is not nil.
|
|
36
|
+
|
|
37
|
+
@param linkName string
|
|
38
|
+
@param parent Instance
|
|
39
|
+
@return Brio<Instance>
|
|
40
|
+
]=]
|
|
34
41
|
function RxLinkUtils.observeLinkValueBrio(linkName, parent)
|
|
35
42
|
assert(type(linkName) == "string", "linkName should be 'string'")
|
|
36
43
|
assert(typeof(parent) == "Instance", "parent should be 'Instance'")
|