Modulo:DTSem: differenze tra le versioni

Vai alla navigazione Vai alla ricerca
Simpler version to extract recurrent characters. Now modular for further reuse.
mNessun oggetto della modifica
(Simpler version to extract recurrent characters. Now modular for further reuse.)
Riga 117: Riga 117:
end
end
    if type(Pages) == "table" then
--return table.concat(Results, string.char(10))
    for _, Page in ipairs(Pages.results) do
    local Count
    local Episodes = {}
        local List = {}
        -- Page.fulltext represents Page name
       
        --Count = mw.smw.ask('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|format=count')
        Episodes = mw.smw.ask('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|sort=Numero di produzione|order=asc')
       
        if (Episodes ~= nil) and (#Episodes > 0) then
        --[=[
        Episodes = mw.smw.getQueryResult('[[Serie::' .. Series .. ']][[Personaggio::' .. Page.fulltext .. ']]|sort=Numero di produzione|order=asc')
       
        for _, Episode in ipairs(Episodes.results) do
        table.insert(List, "[[" .. Episode.fulltext .. "]]")
        end
        ]=]
       
       
        for num, row in pairs(Episodes) do
        --myResult = myResult .. '* This is result #' .. num .. '\n'
            for property, data in pairs( row ) do
            if type( data ) == 'table' then
            table.insert(List, table.concat(data))
            else
            table.insert(List, data)
            end
       
            end
        end
        table.insert(Results, "* '''[[" .. Page.fulltext .. "]]''' (" .. Count .. "): " .. table.concat(List, ", ").. " - " .. #Episodes)
        end
    end
    else
    return "''Il risultato non è una TABLE''"
    end
--return mw.text.nowiki(CategoryText) .. #Pages
return table.concat(Results, string.char(10))
end
end
--- Helper to extract recurring characters and list them
--- Helper to extract recurring characters and list them
Riga 202: Riga 163:
     end
     end
--return mw.text.nowiki(CategoryText) .. #Pages
return table.concat(Results, string.char(10))
return table.concat(Results, string.char(10))
end
end

Menu di navigazione