|
|
| Строка 512: |
Строка 512: |
| end | | end |
| return outLocal | | return outLocal |
| end
| |
|
| |
| function p.get(frame)
| |
| local args = getArgs(frame, { removeBlanks = false })
| |
| local id = args[1] or ""
| |
| if id == "" then return "" end
| |
|
| |
| local filter = build_key_filter(args)
| |
|
| |
| local ignoreComponents = args.ignoreComponents or args.ignoreComponent or ""
| |
| local ignorePrototypes = args.ignorePrototypes or args.ignorePrototype or ""
| |
|
| |
| local componentDefs = load_module_data("component.json")
| |
| local prototypeStoreDefs = load_module_data("prototype_store.json")
| |
| local componentStoreDefs = load_module_data("component_store.json")
| |
| if not componentDefs or not prototypeStoreDefs or not componentStoreDefs then return "" end
| |
|
| |
| local foundComponents, foundPrototypes = collect_entity_sets(id, componentDefs, prototypeStoreDefs, ignoreComponents,
| |
| ignorePrototypes)
| |
| local state = new_switch_state()
| |
|
| |
| local ok, dp = pcall(require, "Module:GetField")
| |
| local errors = {}
| |
|
| |
| local function processEntity(kind, name, isStore)
| |
| local pathName = lcfirst(name)
| |
| local tplPath = kind .. "/" .. pathName
| |
| if isStore then
| |
| tplPath = tplPath .. "/store"
| |
| end
| |
|
| |
| local content = load_template_content(tplPath)
| |
| if not content then
| |
| if filter.hasWhitelist then
| |
| return
| |
| end
| |
| errors[#errors + 1] = build_missing_template_error(kind, name, isStore, tplPath)
| |
| return
| |
| end
| |
|
| |
| local parsed = getTemplateMeta(frame, tplPath)
| |
| if type(parsed) ~= "table" then
| |
| parsed = {}
| |
| end
| |
|
| |
| local extra = ""
| |
| if ok and dp and dp.flattenField then
| |
| local dataPage = tplPath .. ".json"
| |
| extra = dp.flattenField({ args = { id, dataPage } })
| |
| end
| |
|
| |
| add_entries_from_meta(state, parsed, {
| |
| tplPath = tplPath,
| |
| id = id,
| |
| extra = extra,
| |
| source = make_source(kind, name, pathName, tplPath),
| |
| priority = resolve_priority(parsed)
| |
| }, filter, false)
| |
| end
| |
|
| |
| for compName in pairs(foundComponents) do
| |
| processEntity("component", compName, false)
| |
| end
| |
| for protoName in pairs(foundPrototypes) do
| |
| processEntity("prototype", protoName, false)
| |
| end
| |
|
| |
| if type(componentStoreDefs) == "table" then
| |
| local compStore = componentStoreDefs[id]
| |
| if type(compStore) == "table" then
| |
| for compName in pairs(compStore) do
| |
| processEntity("component", compName, true)
| |
| end
| |
| end
| |
| end
| |
|
| |
| if type(prototypeStoreDefs) == "table" then
| |
| local protoStore = prototypeStoreDefs[id]
| |
| if type(protoStore) == "table" then
| |
| for protoName in pairs(protoStore) do
| |
| processEntity("prototype", protoName, true)
| |
| end
| |
| end
| |
| end
| |
|
| |
| local out = {}
| |
|
| |
| if #errors > 0 then
| |
| table.insert(out, '{{сущность/infobox|' .. table.concat(errors, "\n") .. '}}')
| |
| end
| |
|
| |
| local blocks = renderBlocks(frame, state, filter.hasWhitelist, id)
| |
| for _, b in ipairs(blocks) do
| |
| table.insert(out, b)
| |
| end
| |
|
| |
| return frame:preprocess(table.concat(out, "\n") .. "[[Категория:Сущности]]")
| |
| end | | end |
|
| |
|