mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-04 13:23:54 -04:00
Clean up component vs baseComponent
This commit is contained in:
parent
f6536d5a0e
commit
e0f88025ba
5 changed files with 52 additions and 50 deletions
|
@ -6,24 +6,24 @@ local Type = require(PATH..".type")
|
|||
|
||||
local Components = {}
|
||||
|
||||
function Components.register(name, component)
|
||||
function Components.register(name, baseComponent)
|
||||
if (type(name) ~= "string") then
|
||||
error("bad argument #1 to 'Components.register' (string expected, got "..type(name)..")", 3)
|
||||
end
|
||||
|
||||
if (not Type.isComponent(component)) then
|
||||
error("bad argument #2 to 'Components.register' (component expected, got "..type(component)..")", 3)
|
||||
if (not Type.isBaseComponent(baseComponent)) then
|
||||
error("bad argument #2 to 'Components.register' (BaseComponent expected, got "..type(baseComponent)..")", 3)
|
||||
end
|
||||
|
||||
if (rawget(Components, name)) then
|
||||
error("bad argument #2 to 'Components.register' (Component with name '"..name.."' is already registerd)", 3)
|
||||
error("bad argument #2 to 'Components.register' (BaseComponent with name '"..name.."' is already registerd)", 3)
|
||||
end
|
||||
|
||||
Components[name] = component
|
||||
Components[name] = baseComponent
|
||||
end
|
||||
|
||||
return setmetatable(Components, {
|
||||
__index = function(_, name)
|
||||
error("Attempt to index component '"..tostring(name).."' that does not exist / was not registered", 2)
|
||||
error("Attempt to index BaseComponent '"..tostring(name).."' that does not exist / was not registered", 2)
|
||||
end
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue