forked from Bastion/Bastion
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
2 years ago
|
local ClassMagic = {}
|
||
|
ClassMagic.__index = ClassMagic
|
||
|
|
||
|
function ClassMagic:Resolve(Class, key)
|
||
|
if Class[key] or Class[key] == false then
|
||
|
return Class[key]
|
||
|
end
|
||
|
|
||
|
if Class['Get' .. key:sub(1, 1):upper() .. key:sub(2)] then
|
||
|
local func = Class['Get' .. key:sub(1, 1):upper() .. key:sub(2)]
|
||
|
|
||
|
-- Call the function and return the result if there's more than one return value return it as a table
|
||
|
local result = { func(self) }
|
||
|
if #result > 1 then
|
||
|
return result
|
||
|
end
|
||
|
|
||
|
return result[1]
|
||
|
end
|
||
|
|
||
|
|
||
|
if Class['Get' .. key:upper()] then
|
||
|
local func = Class['Get' .. key:upper()]
|
||
|
|
||
|
-- Call the function and return the result if there's more than one return value return it as a table
|
||
|
local result = { func(self) }
|
||
|
if #result > 1 then
|
||
|
return result
|
||
|
end
|
||
|
|
||
|
return result[1]
|
||
|
end
|
||
|
|
||
|
if Class['Is' .. key:upper()] then
|
||
|
local func = Class['Is' .. key:upper()]
|
||
|
|
||
|
-- Call the function and return the result if there's more than one return value return it as a table
|
||
|
local result = { func(self) }
|
||
|
if #result > 1 then
|
||
|
return result
|
||
|
end
|
||
|
|
||
|
return result[1]
|
||
|
end
|
||
|
|
||
|
return Class[key]
|
||
|
end
|
||
|
|
||
|
return ClassMagic
|