@quenty/conditions 10.40.1 → 10.42.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 +10 -0
- package/package.json +8 -8
- package/src/Shared/AdorneeConditionUtils.lua +39 -30
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
# [10.42.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/conditions@10.41.0...@quenty/conditions@10.42.0) (2026-07-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/conditions
|
|
9
|
+
|
|
10
|
+
# [10.41.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/conditions@10.40.1...@quenty/conditions@10.41.0) (2026-07-14)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **conditions:** convert package to --!strict ([666a316](https://github.com/Quenty/NevermoreEngine/commit/666a31652d6f457697505c4318911fbb50db0496))
|
|
15
|
+
|
|
6
16
|
## [10.40.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/conditions@10.40.0...@quenty/conditions@10.40.1) (2026-05-30)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @quenty/conditions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/conditions",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.42.0",
|
|
4
4
|
"description": "Adornee based conditional system that is sufficiently generic to script gameplay.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"preinstall": "npx only-allow pnpm"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@quenty/attributeutils": "14.
|
|
30
|
-
"@quenty/brio": "14.
|
|
31
|
-
"@quenty/instanceutils": "13.
|
|
29
|
+
"@quenty/attributeutils": "14.31.0",
|
|
30
|
+
"@quenty/brio": "14.31.0",
|
|
31
|
+
"@quenty/instanceutils": "13.31.0",
|
|
32
32
|
"@quenty/loader": "10.11.0",
|
|
33
33
|
"@quenty/maid": "3.9.0",
|
|
34
34
|
"@quenty/nevermore-test-runner": "1.4.0",
|
|
35
|
-
"@quenty/rx": "13.
|
|
36
|
-
"@quenty/statestack": "14.
|
|
37
|
-
"@quenty/tie": "10.
|
|
35
|
+
"@quenty/rx": "13.29.0",
|
|
36
|
+
"@quenty/statestack": "14.33.0",
|
|
37
|
+
"@quenty/tie": "10.42.0"
|
|
38
38
|
},
|
|
39
39
|
"contributors": [
|
|
40
40
|
"Quenty"
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "cbbb89635bfdcbf32f26a40422ac736292917cca"
|
|
46
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
--!
|
|
1
|
+
--!strict
|
|
2
2
|
--[=[
|
|
3
3
|
Utility library that defines a generalized interface for scriptable conditions. These conditions are rooted in [Rx] and
|
|
4
4
|
can be scripted by a variety of systems. For example, we may have conditions on what ammo we can consume, or whether
|
|
@@ -75,7 +75,10 @@ local AdorneeConditionUtils = {}
|
|
|
75
75
|
@param adornee -- Adornee to check conditions on
|
|
76
76
|
@return Observable<boolean>
|
|
77
77
|
]=]
|
|
78
|
-
function AdorneeConditionUtils.observeConditionsMet(
|
|
78
|
+
function AdorneeConditionUtils.observeConditionsMet(
|
|
79
|
+
conditionObj: BindableFunction,
|
|
80
|
+
adornee: Instance
|
|
81
|
+
): Observable.Observable<boolean>
|
|
79
82
|
assert(typeof(conditionObj) == "Instance" and conditionObj:IsA("BindableFunction"), "Bad conditionObj")
|
|
80
83
|
assert(typeof(adornee) == "Instance", "Bad adornee")
|
|
81
84
|
|
|
@@ -99,7 +102,7 @@ function AdorneeConditionUtils.promiseQueryConditionsMet(
|
|
|
99
102
|
assert(typeof(conditionObj) == "Instance" and conditionObj:IsA("BindableFunction"), "Bad condition")
|
|
100
103
|
assert(typeof(adornee) == "Instance", "Bad adornee")
|
|
101
104
|
|
|
102
|
-
return Rx.toPromise(AdorneeConditionUtils.observeConditionsMet(conditionObj, adornee), cancelToken)
|
|
105
|
+
return Rx.toPromise(AdorneeConditionUtils.observeConditionsMet(conditionObj, adornee) :: any, cancelToken)
|
|
103
106
|
end
|
|
104
107
|
|
|
105
108
|
--[=[
|
|
@@ -123,7 +126,7 @@ end
|
|
|
123
126
|
@param observeCallback function
|
|
124
127
|
@return BindableFunction
|
|
125
128
|
]=]
|
|
126
|
-
function AdorneeConditionUtils.create(observeCallback): BindableFunction
|
|
129
|
+
function AdorneeConditionUtils.create(observeCallback: (adornee: Instance) -> any): BindableFunction
|
|
127
130
|
assert(type(observeCallback) == "function", "Bad observeCallback")
|
|
128
131
|
|
|
129
132
|
local condition = Instance.new("BindableFunction")
|
|
@@ -145,8 +148,8 @@ function AdorneeConditionUtils.createRequiredProperty(propertyName: string, requ
|
|
|
145
148
|
assert(type(propertyName) == "string", "Bad propertyName")
|
|
146
149
|
|
|
147
150
|
local condition = AdorneeConditionUtils.create(function(adornee: Instance)
|
|
148
|
-
return RxInstanceUtils.observeProperty(adornee, propertyName):Pipe({
|
|
149
|
-
Rx.map(function(value)
|
|
151
|
+
return (RxInstanceUtils.observeProperty(adornee, propertyName) :: any):Pipe({
|
|
152
|
+
Rx.map(function(value): any
|
|
150
153
|
return value == requiredValue
|
|
151
154
|
end),
|
|
152
155
|
})
|
|
@@ -171,8 +174,8 @@ function AdorneeConditionUtils.createRequiredAttribute(attributeName: string, at
|
|
|
171
174
|
assert(type(attributeName) == "string", "Bad attributeName")
|
|
172
175
|
|
|
173
176
|
local condition = AdorneeConditionUtils.create(function(adornee: Instance)
|
|
174
|
-
return RxAttributeUtils.observeAttribute(adornee, attributeName):Pipe({
|
|
175
|
-
Rx.map(function(value)
|
|
177
|
+
return (RxAttributeUtils.observeAttribute(adornee, attributeName) :: any):Pipe({
|
|
178
|
+
Rx.map(function(value): any
|
|
176
179
|
return value == attributeValue
|
|
177
180
|
end),
|
|
178
181
|
})
|
|
@@ -192,7 +195,7 @@ end
|
|
|
192
195
|
@param tieInterfaceDefinition TieDefinition
|
|
193
196
|
@return BindableFunction
|
|
194
197
|
]=]
|
|
195
|
-
function AdorneeConditionUtils.createRequiredTieInterface(tieInterfaceDefinition): BindableFunction
|
|
198
|
+
function AdorneeConditionUtils.createRequiredTieInterface(tieInterfaceDefinition: any): BindableFunction
|
|
196
199
|
assert(tieInterfaceDefinition, "Bad tieInterfaceDefinition")
|
|
197
200
|
|
|
198
201
|
local condition = AdorneeConditionUtils.create(function(adornee: Instance)
|
|
@@ -214,7 +217,7 @@ end
|
|
|
214
217
|
@return BindableFunction
|
|
215
218
|
]=]
|
|
216
219
|
function AdorneeConditionUtils.createOrConditionGroup(): BindableFunction
|
|
217
|
-
local container
|
|
220
|
+
local container: BindableFunction
|
|
218
221
|
container = AdorneeConditionUtils.create(function(adornee: Instance)
|
|
219
222
|
assert(container, "Should not be invoking this on construction before container is assigned")
|
|
220
223
|
|
|
@@ -235,7 +238,7 @@ end
|
|
|
235
238
|
@return BindableFunction
|
|
236
239
|
]=]
|
|
237
240
|
function AdorneeConditionUtils.createAndConditionGroup(): BindableFunction
|
|
238
|
-
local container
|
|
241
|
+
local container: BindableFunction
|
|
239
242
|
container = AdorneeConditionUtils.create(function(adornee: Instance)
|
|
240
243
|
assert(container, "Should not be invoking this on construction before container is assigned")
|
|
241
244
|
|
|
@@ -284,7 +287,7 @@ end
|
|
|
284
287
|
@param container BindableFunction
|
|
285
288
|
@param value boolean -- Value to default to
|
|
286
289
|
]=]
|
|
287
|
-
function AdorneeConditionUtils.setValueWhenEmpty(container, value)
|
|
290
|
+
function AdorneeConditionUtils.setValueWhenEmpty(container: BindableFunction, value: boolean): ()
|
|
288
291
|
assert(typeof(container) == "Instance", "Bad container")
|
|
289
292
|
assert(type(value) == "boolean", "Bad value")
|
|
290
293
|
|
|
@@ -297,7 +300,7 @@ end
|
|
|
297
300
|
@param container BindableFunction
|
|
298
301
|
@return boolean
|
|
299
302
|
]=]
|
|
300
|
-
function AdorneeConditionUtils.getValueWhenEmpty(container: BindableFunction)
|
|
303
|
+
function AdorneeConditionUtils.getValueWhenEmpty(container: BindableFunction): boolean
|
|
301
304
|
assert(typeof(container) == "Instance", "Bad container")
|
|
302
305
|
|
|
303
306
|
return AttributeUtils.getAttribute(container, VALUE_WHEN_EMPTY_ATTRIBUTE, DEFAULT_VALUE_WHEN_EMPTY_WHEN_UNDEFINED)
|
|
@@ -308,7 +311,7 @@ end
|
|
|
308
311
|
@param container BindableFunction
|
|
309
312
|
@return Observable<boolean>
|
|
310
313
|
]=]
|
|
311
|
-
function AdorneeConditionUtils.observeValueWhenEmpty(container: BindableFunction)
|
|
314
|
+
function AdorneeConditionUtils.observeValueWhenEmpty(container: BindableFunction): Observable.Observable<boolean>
|
|
312
315
|
assert(typeof(container) == "Instance", "Bad container")
|
|
313
316
|
|
|
314
317
|
return RxAttributeUtils.observeAttribute(
|
|
@@ -321,13 +324,13 @@ end
|
|
|
321
324
|
--[[
|
|
322
325
|
Maps the given object to "and"
|
|
323
326
|
]]
|
|
324
|
-
function AdorneeConditionUtils._mapToAnd(observeValueWhenEmpty)
|
|
327
|
+
function AdorneeConditionUtils._mapToAnd(observeValueWhenEmpty: any): any
|
|
325
328
|
assert(observeValueWhenEmpty, "Bad observeValueWhenEmpty")
|
|
326
329
|
|
|
327
|
-
return function(source)
|
|
330
|
+
return function(source: any)
|
|
328
331
|
assert(source, "No source")
|
|
329
332
|
|
|
330
|
-
return Observable.new(function(sub)
|
|
333
|
+
return Observable.new(function(sub: any)
|
|
331
334
|
local topMaid = Maid.new()
|
|
332
335
|
|
|
333
336
|
local isDisabled = topMaid:Add(StateStack.new(false, "boolean"))
|
|
@@ -359,7 +362,7 @@ function AdorneeConditionUtils._mapToAnd(observeValueWhenEmpty)
|
|
|
359
362
|
update()
|
|
360
363
|
|
|
361
364
|
topMaid:GiveTask(
|
|
362
|
-
source:Subscribe(function(observableBrio)
|
|
365
|
+
source:Subscribe(function(observableBrio: any)
|
|
363
366
|
if observableBrio:IsDead() then
|
|
364
367
|
return
|
|
365
368
|
end
|
|
@@ -396,13 +399,13 @@ end
|
|
|
396
399
|
--[[
|
|
397
400
|
Maps the given object to "or"
|
|
398
401
|
]]
|
|
399
|
-
function AdorneeConditionUtils._mapToOr(observeValueWhenEmpty)
|
|
402
|
+
function AdorneeConditionUtils._mapToOr(observeValueWhenEmpty: any): any
|
|
400
403
|
assert(observeValueWhenEmpty, "Bad observeValueWhenEmpty")
|
|
401
404
|
|
|
402
|
-
return function(source)
|
|
405
|
+
return function(source: any)
|
|
403
406
|
assert(source, "No source")
|
|
404
407
|
|
|
405
|
-
return Observable.new(function(sub)
|
|
408
|
+
return Observable.new(function(sub: any)
|
|
406
409
|
local topMaid = Maid.new()
|
|
407
410
|
|
|
408
411
|
local isEnabled = topMaid:Add(StateStack.new(false, "boolean"))
|
|
@@ -434,7 +437,7 @@ function AdorneeConditionUtils._mapToOr(observeValueWhenEmpty)
|
|
|
434
437
|
update()
|
|
435
438
|
|
|
436
439
|
topMaid:GiveTask(
|
|
437
|
-
source:Subscribe(function(observableBrio)
|
|
440
|
+
source:Subscribe(function(observableBrio: any)
|
|
438
441
|
if observableBrio:IsDead() then
|
|
439
442
|
return
|
|
440
443
|
end
|
|
@@ -473,14 +476,17 @@ end
|
|
|
473
476
|
|
|
474
477
|
@return Observable<Observable<boolean>>
|
|
475
478
|
]]
|
|
476
|
-
function AdorneeConditionUtils._observeConditionObservablesBrio(
|
|
479
|
+
function AdorneeConditionUtils._observeConditionObservablesBrio(
|
|
480
|
+
parent: Instance,
|
|
481
|
+
adornee: Instance
|
|
482
|
+
): Observable.Observable<any>
|
|
477
483
|
assert(typeof(parent) == "Instance", "Bad parent")
|
|
478
484
|
assert(typeof(adornee) == "Instance", "Bad adornee")
|
|
479
485
|
|
|
480
|
-
return RxInstanceUtils.observeChildrenBrio(parent, function(child)
|
|
486
|
+
return (RxInstanceUtils.observeChildrenBrio(parent, function(child)
|
|
481
487
|
return child:IsA("BindableFunction") and CollectionService:HasTag(child, AdorneeConditionUtils.getRequiredTag())
|
|
482
|
-
end):Pipe({
|
|
483
|
-
RxBrioUtils.map(function(conditionObj)
|
|
488
|
+
end) :: any):Pipe({
|
|
489
|
+
RxBrioUtils.map(function(conditionObj): any
|
|
484
490
|
return AdorneeConditionUtils._getObservableFromConditionObj(conditionObj, adornee)
|
|
485
491
|
end),
|
|
486
492
|
})
|
|
@@ -492,12 +498,15 @@ end
|
|
|
492
498
|
|
|
493
499
|
@return Observable<boolean>
|
|
494
500
|
]]
|
|
495
|
-
function AdorneeConditionUtils._getObservableFromConditionObj(
|
|
501
|
+
function AdorneeConditionUtils._getObservableFromConditionObj(
|
|
502
|
+
conditionObj: Instance,
|
|
503
|
+
adornee: Instance
|
|
504
|
+
): Observable.Observable<boolean>
|
|
496
505
|
local observable
|
|
497
506
|
local current
|
|
498
507
|
task.spawn(function()
|
|
499
508
|
current = coroutine.running()
|
|
500
|
-
observable = TieUtils.invokeEncodedBindableFunction(conditionObj, adornee)
|
|
509
|
+
observable = TieUtils.invokeEncodedBindableFunction(conditionObj :: any, adornee)
|
|
501
510
|
end)
|
|
502
511
|
|
|
503
512
|
-- TODO: Allow yielding here
|
|
@@ -508,7 +517,7 @@ function AdorneeConditionUtils._getObservableFromConditionObj(conditionObj: Inst
|
|
|
508
517
|
conditionObj:GetFullName()
|
|
509
518
|
)
|
|
510
519
|
)
|
|
511
|
-
return Rx.EMPTY
|
|
520
|
+
return Rx.EMPTY :: any
|
|
512
521
|
end
|
|
513
522
|
|
|
514
523
|
-- TODO: Allow non-observables.
|
|
@@ -520,7 +529,7 @@ function AdorneeConditionUtils._getObservableFromConditionObj(conditionObj: Inst
|
|
|
520
529
|
tostring(observable)
|
|
521
530
|
)
|
|
522
531
|
)
|
|
523
|
-
return Rx.EMPTY
|
|
532
|
+
return Rx.EMPTY :: any
|
|
524
533
|
end
|
|
525
534
|
|
|
526
535
|
return observable
|