Add helper functions to container. Allow name to be gotten

This commit is contained in:
Tjakka5 2020-01-04 13:40:18 +01:00
parent 6cd66e6737
commit 55ae5fd987
8 changed files with 97 additions and 2 deletions

View file

@ -24,8 +24,24 @@ function Assemblages.register(name, assemblage)
end
Assemblages[name] = assemblage
assemblage.__name = name
end
--- Returns true if the containter has the Assemblage with the name
-- @param name Name of the Assemblage to check
-- @return True if the containter has the Assemblage with the name, false otherwise
function Assemblages.has(name)
return Assemblages[name] and true or false
end
--- Returns the Assemblage with the name
-- @param name Name of the Assemblage to get
-- @return Assemblage with the name
function Assemblages.get(name)
return Assemblages[name]
end
return setmetatable(Assemblages, {
__index = function(_, name)
error("Attempt to index assemblage '"..tostring(name).."' that does not exist / was not registered", 2)