added a component wrapper, for abstraction purposes.
This commit is contained in:
parent
d23768f941
commit
5300a21a37
47
modules/base/component.lua
Normal file
47
modules/base/component.lua
Normal file
@ -0,0 +1,47 @@
|
||||
do
|
||||
local oldcomp = component
|
||||
_G.component = {}
|
||||
for k,v in pairs(oldcomp) do
|
||||
component[k] = v
|
||||
end
|
||||
for c,t in oldcomp.list() do
|
||||
component[c:sub(1,8)] = oldcomp.proxy(c)
|
||||
component[c] = oldcomp.proxy(c)
|
||||
if not component[t] then
|
||||
component[t] = oldcomp.proxy(c)
|
||||
end
|
||||
end
|
||||
function component.list(filter,exact)
|
||||
local ct = {}
|
||||
for k,v in pairs(component) do
|
||||
if type(v) == "table" then
|
||||
if filter then
|
||||
if exact then
|
||||
if v.type == filter or v.address == filter then
|
||||
ct[v.address] = v.type
|
||||
end
|
||||
else
|
||||
if v.type:find(filter) or v.address:find(filter) then
|
||||
ct[v.address] = v.type
|
||||
end
|
||||
end
|
||||
else
|
||||
ct[v.address] = v.type
|
||||
end
|
||||
end
|
||||
end
|
||||
return function(a,b)
|
||||
return next(ct,b)
|
||||
end
|
||||
end
|
||||
--[[ function component.proxy(k)
|
||||
if type(component[k]) == "table" then
|
||||
return component[k]
|
||||
end
|
||||
end
|
||||
function component.type(k)
|
||||
if type(component[k]) == "table" then
|
||||
return component[k].type
|
||||
end
|
||||
end]]--
|
||||
end
|
Loading…
Reference in New Issue
Block a user