Modul:Test: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
imported>Admin |
imported>Admin |
||
| Zeile 51: | Zeile 51: | ||
local entity = mw.wikibase.getEntity(qid) | local entity = mw.wikibase.getEntity(qid) | ||
| − | local snaks = entity['claims'][pid][1]['qualifiers'] | + | local snaks = entity['claims'][pid][1]['qualifiers'][1] |
local test = mw.wikibase.formatValues( snaks ) | local test = mw.wikibase.formatValues( snaks ) | ||
return 'P-ID: ' .. pid .. ' Q-ID: ' .. qid .. ' Test: ' .. test | return 'P-ID: ' .. pid .. ' Q-ID: ' .. qid .. ' Test: ' .. test | ||
Version vom 28. Mai 2020, 13:59 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Test/Doku erstellt werden
-- Das Modul enthält einige Testfunktionen, um das Skripting mit Lua zu erproben
local p = {};
p.getEntity = function (frame)
local qid = frame.args.qid
local entity = mw.wikibase.getEntity(qid)
return entity
end
p.getEntity = function ()
local qid = "P2"
local entity = mw.wikibase.getEntity(qid)
return entity
end
p.getStatement = function (frame)
local pid = frame.args.pid
local qid = frame.args.qid
local entity = mw.wikibase.getEntity(qid)
return entity:formatPropertyValues(pid)
end
p.getLabel = function (frame)
local pid = frame.args.pid
local label = mw.wikibase.getLabel(pid)
return label
end
p.hello = function( frame )
local str = "Hello World!"
return str
end
function p.hello_to(frame)
local name = frame.args[1]
return "Hello, " .. name .. "!"
end
function p.count_fruit(frame)
local num_bananas = frame.args.bananas
local num_apples = frame.args.apples
return 'I have ' .. num_bananas .. ' bananas and ' .. num_apples .. ' apples'
end
function p.Eigenschaft(frame)
local pid = frame.args.pid
local qid = frame.args.qid
local entity = mw.wikibase.getEntity(qid)
local snaks = entity['claims'][pid][1]['qualifiers'][1]
local test = mw.wikibase.formatValues( snaks )
return 'P-ID: ' .. pid .. ' Q-ID: ' .. qid .. ' Test: ' .. test
end
return p