mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
Spinning objects
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user