Zum Inhalt springen

„Modul:Benutzer:Reinhard Kraasch/MyScript.lua“ – Versionsunterschied

aus Wikipedia, der freien Enzyklopädie
[gesichtete Version][gesichtete Version]
Inhalt gelöscht Inhalt hinzugefügt
KKeine Bearbeitungszusammenfassung
KKeine Bearbeitungszusammenfassung
Zeile 28: Zeile 28:
for k, v in pairs(props) do
for k, v in pairs(props) do
pl = mw.wikibase.getLabel(v)
pl = mw.wikibase.getLabel(v)
t = k .. ": " .. v .. " (" .. pl .. ") = "
-- pl = mw.wikibase.getLabel(v)
pv = entity:formatPropertyValues(v)
s = s .. k .. ": " .. v .. pl .. "\n"
for j, vv in pairs(pv) do
s = s .. t .. j .. vv .. "\n"
t = string.sub(' ',1,string.len(t))
end
end
end
return "<pre>" .. s .. "</pre>"
return "<pre>" .. s .. "</pre>"

Version vom 11. April 2018, 17:43 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Benutzer:Reinhard Kraasch/MyScript.lua/Doku erstellt werden

local p = {} 
--local wd = require('Module:Wikidata')

function p.hello(frame)
    local name = frame.args[1]
    if not name then 
        name = 'Welt' 
    end
    return  'Hallo, ' .. name .. '! Dies ist Lua!' 
end 

function p.accessPage(frame)
    id  = mw.wikibase.getEntityIdForTitle( 'Berlin' )
    url = mw.wikibase.getEntityUrl(id)
    return url
end

function p.accessData(frame)
    prop = -1
    local arg = frame.args[1]
    if not arg then 
        arg = 'Berlin' 
    end
    s = ""
    id  = mw.wikibase.getEntityIdForTitle( arg )
    entity = mw.wikibase.getEntity( id )
    props = entity:getProperties()
    for k, v in pairs(props) do
    	pl = mw.wikibase.getLabel(v)
        t = k .. ": " .. v .. " (" .. pl .. ") = " 
    	pv = entity:formatPropertyValues(v)
    	for j, vv in pairs(pv) do
    		s = s .. t .. j .. vv .. "\n"
    		t = string.sub('                                                                                    ',1,string.len(t))
    	end
    end
    return "<pre>" .. s .. "</pre>"
end

function p.getFinchLabel(frame)
    id = 'Q167'
    finchLabel = mw.wikibase.getLabel(id)
    return finchLabel
end
return p