Spinning objects

This commit is contained in:
2024-04-01 22:59:28 -04:00
parent ef8ceb723f
commit be99c7d986
8 changed files with 122 additions and 65 deletions

View File

@@ -2,28 +2,30 @@
--!native
--!strict
type Error = never
type ClassConstructor = typeof(setmetatable({} :: Constructor_Return_Props, {} :: Impl_Constructor))
type Impl_Constructor = {
__index: Impl_Constructor,
constructor: Constructor_Fun,
--Class functions
Nuke: (self: ClassConstructor) -> (),
Nuke: (self: ClassConstructor) -> (),
Request: (self: ClassConstructor, Name: string) -> TagProduct | Error
}
type Constructor_Fun = () -> ClassConstructor
type Constructor_Return_Props = {
Exports: ExportedTags
__export: ExportedTags
}
export type ExportedTags = {
[string]: Instance | {Instance}
}
export type TagProduct = Instance | {Instance}
export type ExportedTags = {[string]: TagProduct}
export type TagsConstructor = ClassConstructor
local Tags = {} :: Impl_Constructor
Tags.__index = Tags
local CS = game:GetService("CollectionService")
local CS: CollectionService = game:GetService("CollectionService")
function Tags.constructor()
local Exports: ExportedTags = {}
@@ -34,15 +36,20 @@ function Tags.constructor()
local Tagged = CS:GetTagged(TagName)
Exports[TagName] = #Tagged>1 and Tagged or Tagged[1]
end
return setmetatable({
Exports = Exports
__export = Exports
}, Tags)
end
function Tags:Nuke()
local Exports = self.Exports
function Tags:Request(Name)
return self.__export[Name] or error(`Error requesting tag name, tag name "{Name}" does not exist`, 2)
end
for i: string, v: Instance | {Instance} in Exports do
function Tags:Nuke()
local Exports = self.__export
for i: string, v: TagProduct in Exports do
if type(v) == "table" then
for n: number = 1, #v do
CS:RemoveTag(v[n], i)