mirror of
https://github.com/unixtensor/Roblox-Elevator-Game.git
synced 2025-12-14 14:51:55 +00:00
test
This commit is contained in:
@@ -4,7 +4,11 @@
|
|||||||
|
|
||||||
type EnumValue = any
|
type EnumValue = any
|
||||||
type EnumName = string
|
type EnumName = string
|
||||||
|
type MatchResult = any?
|
||||||
|
|
||||||
|
type MatchList_f = {[string]: (...any?) -> MatchResult}
|
||||||
type Enums = {[EnumName]: EnumValue}
|
type Enums = {[EnumName]: EnumValue}
|
||||||
|
|
||||||
type EnumsMetadata = {
|
type EnumsMetadata = {
|
||||||
__index: (self: EnumsMetadata, i: EnumName) -> EnumValue?,
|
__index: (self: EnumsMetadata, i: EnumName) -> EnumValue?,
|
||||||
__newindex: (self: EnumsMetadata, i: EnumName, v: EnumValue) -> ()
|
__newindex: (self: EnumsMetadata, i: EnumName, v: EnumValue) -> ()
|
||||||
@@ -19,9 +23,6 @@ type CustonEnumsFunctions = {
|
|||||||
Remove: (Name: EnumName) -> ()
|
Remove: (Name: EnumName) -> ()
|
||||||
}
|
}
|
||||||
|
|
||||||
type MatchResult = any?
|
|
||||||
type MatchList_f = {[string]: (...any?) -> MatchResult}
|
|
||||||
|
|
||||||
local CustomEnum = {} :: CustomEnums
|
local CustomEnum = {} :: CustomEnums
|
||||||
local EnumMeta = {} :: EnumsMetadata
|
local EnumMeta = {} :: EnumsMetadata
|
||||||
|
|
||||||
@@ -50,22 +51,28 @@ end
|
|||||||
CustomEnum.Enums = setmetatable({}, EnumMeta)
|
CustomEnum.Enums = setmetatable({}, EnumMeta)
|
||||||
|
|
||||||
local function EnumMethods(Enum)
|
local function EnumMethods(Enum)
|
||||||
--Branch this out later
|
--Branch these out later
|
||||||
function Enum:Match(Result: string, MatchList: MatchList_f): MatchResult
|
function Enum:Match(Result: string, MatchList: MatchList_f): MatchResult
|
||||||
local Return: MatchResult = nil
|
local Return: MatchResult = nil
|
||||||
local b: boolean = false
|
|
||||||
|
|
||||||
for MatchEnumName, EnumFunc in MatchList do
|
for MatchEnumName: string, EnumFunc in MatchList do
|
||||||
if MatchEnumName == Result then
|
if MatchEnumName == Result then
|
||||||
Return = EnumFunc()
|
Return = type(EnumFunc) == "function" and EnumFunc() or EnumFunc
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not Return and MatchList["_"] then
|
if Return ~= nil and MatchList["_"] then
|
||||||
Return = MatchList["_"]()
|
Return = MatchList["_"]()
|
||||||
end
|
end
|
||||||
return Return
|
return Return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Enum:MatchThread(Result: string, MatchList: MatchList_f): (boolean, MatchResult)
|
||||||
|
task.synchronize()
|
||||||
|
return coroutine.resume(coroutine.create(function()
|
||||||
|
return self:Match(Result, MatchList)
|
||||||
|
end))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function CustomEnum.Create(Name, EnumValue)
|
function CustomEnum.Create(Name, EnumValue)
|
||||||
Reference in New Issue
Block a user