@rbxts/prototype 0.0.5 → 0.0.6
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/out/prototype.d.ts +3 -0
- package/out/prototype.lua +22 -0
- package/package.json +1 -1
package/out/prototype.d.ts
CHANGED
|
@@ -59,6 +59,9 @@ export declare class PrototypeHandler {
|
|
|
59
59
|
/** @metadata macro */
|
|
60
60
|
TryIndex<T extends IPrototype>(prototypeId: string, kindName?: Modding.Generic<T, "text"> | string): [success: false] | [success: true, prototype: T];
|
|
61
61
|
TryIndex(prototypeId: string, kindName: string): [success: false] | [success: true, prototype: IPrototype];
|
|
62
|
+
/** @metadata macro */
|
|
63
|
+
Index<T extends IPrototype>(prototypeId: string, kindName?: Modding.Generic<T, "text"> | string): T;
|
|
64
|
+
Index(prototypeId: string, kindName: string): IPrototype;
|
|
62
65
|
Compile(): void;
|
|
63
66
|
RegisterPrototype(prototype: IPrototype, kindName: string): void;
|
|
64
67
|
}
|
package/out/prototype.lua
CHANGED
|
@@ -390,6 +390,28 @@ do
|
|
|
390
390
|
local _prototypeId_1 = prototypeId
|
|
391
391
|
return { true, _instances_1[_prototypeId_1].Instance }
|
|
392
392
|
end
|
|
393
|
+
function PrototypeHandler:Index(prototypeId, kindName)
|
|
394
|
+
local _prototypes = self.prototypes
|
|
395
|
+
local _kindName = kindName
|
|
396
|
+
local kind = _prototypes[_kindName]
|
|
397
|
+
if not kind then
|
|
398
|
+
error(`Prototype with kind key: {kindName} does not exist. PrototypeId: {prototypeId}`)
|
|
399
|
+
end
|
|
400
|
+
local _instances = kind.Instances
|
|
401
|
+
local _prototypeId = prototypeId
|
|
402
|
+
local _condition = not (_instances[_prototypeId] ~= nil)
|
|
403
|
+
if not _condition then
|
|
404
|
+
local _instances_1 = kind.Instances
|
|
405
|
+
local _prototypeId_1 = prototypeId
|
|
406
|
+
_condition = not _instances_1[_prototypeId_1].Instance
|
|
407
|
+
end
|
|
408
|
+
if _condition then
|
|
409
|
+
error(`Prototype with id: {prototypeId} does not exist`)
|
|
410
|
+
end
|
|
411
|
+
local _instances_1 = kind.Instances
|
|
412
|
+
local _prototypeId_1 = prototypeId
|
|
413
|
+
return _instances_1[_prototypeId_1].Instance
|
|
414
|
+
end
|
|
393
415
|
function PrototypeHandler:Compile()
|
|
394
416
|
local ids = {}
|
|
395
417
|
for id, Kind in self.allRegisteredPrototypes do
|