| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- -- add empty ccslog function to avoid function not defined error.
- -- if you log something, add what you want in it.
- if cc.exports then
- cc.exports.ccslog = function(...) end
- else
- ccslog = function(...) end
- end
- -- used as metaTable
- local luaExtend = {}
- local function getChildInSubNodes(nodeTable, key)
- if #nodeTable == 0 then
- return nil
- end
- local child = nil
- local subNodeTable = {}
- for _, v in ipairs(nodeTable) do
- child = v:getChildByName(key)
- if (child) then
- return child
- end
- end
- for _, v in ipairs(nodeTable) do
- local subNodes = v:getChildren()
- if #subNodes ~= 0 then
- for _, v1 in ipairs(subNodes) do
- table.insert(subNodeTable, v1)
- end
- end
- end
- return getChildInSubNodes(subNodeTable, key)
- end
- luaExtend.__index = function(table, key)
- local root = table.root
- local child = root[key]
- if child then
- return child
- end
- child = root:getChildByName(key)
- if child then
- root[key] = child
- return child
- end
- child = getChildInSubNodes(root:getChildren(), key)
- if child then root[key] = child end
- return child
- end
- -- used as metaTable
- return luaExtend
|