Automate naming process

This commit is contained in:
Tjakka5 2019-12-22 23:07:42 +01:00
parent e0f88025ba
commit 144a42dc9e
7 changed files with 78 additions and 53 deletions

View file

@ -1,26 +1,17 @@
--- Component
local PATH = (...):gsub('%.[^%.]+$', '')
local Components = require(PATH..".components")
local Component = {}
Component.__index = Component
--- Creates a new Component.
-- @param populate A function that populates the Bag with values
-- @return A Component object
function Component.new(name, populate)
if (type(name) ~= "string") then
error("bad argument #1 to 'Component.new' (string expected, got "..type(name)..")", 2)
end
function Component.new(populate)
if not (type(populate) == "function") then
error("bad argument #2 to 'Component.new' (function expected, got "..type(populate)..")", 2)
error("bad argument #1 to 'Component.new' (function expected, got "..type(populate)..")", 2)
end
local baseComponent = setmetatable({
__name = name,
__populate = populate,
__isBaseComponent = true,
@ -28,8 +19,6 @@ function Component.new(name, populate)
baseComponent.__mt = {__index = baseComponent}
Components.register(name, baseComponent)
return baseComponent
end