mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-02 04:13:58 -04:00
Allow for blank components
This commit is contained in:
parent
144a42dc9e
commit
a8bc92a951
2 changed files with 7 additions and 6 deletions
6
main.lua
6
main.lua
|
@ -29,9 +29,7 @@ end)
|
|||
Components.register("test_comp_2", test_comp_2)
|
||||
|
||||
|
||||
local test_comp_3 = Component(function(e, b)
|
||||
e.b = b
|
||||
end)
|
||||
local test_comp_3 = Component()
|
||||
Components.register("test_comp_3", test_comp_3)
|
||||
|
||||
|
||||
|
@ -72,7 +70,7 @@ entity
|
|||
:give(Components.test_comp_1, 100, 100)
|
||||
:remove(Components.test_comp_1)
|
||||
:give(Components.test_comp_1, 200, 100)
|
||||
|
||||
:give(Components.test_comp_3, 200, 100)
|
||||
|
||||
Worlds.testWorld:addEntity(entity)
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ Component.__index = Component
|
|||
-- @param populate A function that populates the Bag with values
|
||||
-- @return A Component object
|
||||
function Component.new(populate)
|
||||
if not (type(populate) == "function") then
|
||||
error("bad argument #1 to 'Component.new' (function expected, got "..type(populate)..")", 2)
|
||||
if (type(populate) ~= "function" and type(populate) ~= "nil") then
|
||||
error("bad argument #1 to 'Component.new' (function/nil expected, got "..type(populate)..")", 2)
|
||||
end
|
||||
|
||||
local baseComponent = setmetatable({
|
||||
|
@ -22,6 +22,9 @@ function Component.new(populate)
|
|||
return baseComponent
|
||||
end
|
||||
|
||||
function Component:__populate() -- luacheck: ignore
|
||||
end
|
||||
|
||||
--- Creates and initializes a new Component.
|
||||
-- @param ... The values passed to the populate function
|
||||
-- @return A new initialized Component
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue