Sacra.Wiki Modul:RandomPerson: Unterschied zwischen den Versionen

Modul:RandomPerson: Unterschied zwischen den Versionen

Aus Sacra.Wiki
Zeile 6: Zeile 6:
end
end


local queryResult = mw.smw.ask("[[Kategorie:Person]]|?Bildname|limit=3|order=random")
local queryResult = mw.smw.ask("[[Kategorie:Person]]|?Name|?Bildname|limit=3|order=random")
if queryResult == nil then
if queryResult == nil then

Version vom 19. Oktober 2021, 10:35 Uhr

Die Dokumentation für dieses Modul kann unter Modul:RandomPerson/Doku erstellt werden

local p = {}

function p.ask()
	if not mw.smw then
        return "mw.smw module not found"
	end

	local queryResult = mw.smw.ask("[[Kategorie:Person]]|?Name|?Bildname|limit=3|order=random")
	
	if queryResult == nil then
        return "(no values)"
	end
	return mw.dumpObject(queryResult)
	--[[
	if type( queryResult ) == "table" then
        local myResult = ""
        for num, row in pairs( queryResult ) do
            myResult = myResult .. '* This is result #' .. num .. '\n'
            for property, data in pairs( row ) do
                local dataOutput = data
                if type( data ) == 'table' then
                    dataOutput = mw.text.listToText( data, ', ', ' and ')
                end
                myResult = myResult .. '** ' .. property .. ': ' .. dataOutput .. '\n'
            end
        end
        return myResult
    end
    ]]--
end

return p
Cookies helfen uns bei der Bereitstellung von Sacra.Wiki. Durch die Nutzung von Sacra.Wiki erklärst du dich damit einverstanden, dass wir Cookies speichern.