„Modul:Benutzer:Recompile/MyScript.lua“ – Versionsunterschied
Erscheinungsbild
[gesichtete Version] | [gesichtete Version] |
Inhalt gelöscht Inhalt hinzugefügt
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 39: | Zeile 39: | ||
-- res = res .. ", " .. string.format("%s", v) |
-- res = res .. ", " .. string.format("%s", v) |
||
end |
end |
||
return # (property |
return # (pairs(property)) |
||
end |
end |
||
Version vom 4. März 2018, 13:14 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Benutzer:Recompile/MyScript.lua/Doku erstellt werden
local p = {}
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.apples(frame)
return 'Or pears?'
end
function p.chocolate(frame)
return 'And mayonese!'
end
function p.accessPage(frame)
id = mw.wikibase.getEntityIdForTitle( 'Berlin' )
url = mw.wikibase.getEntityUrl(id)
return url
end
function p.accessData(frame)
prop = -1
id = mw.wikibase.getEntityIdForTitle( 'Berlin' )
entity = mw.wikibase.getEntity( id )
props = entity:getProperties()
for k, v in pairs(props) do
if v == 'P17' then
prop = v
end
end
res = ""
property = entity.claims[ 'P571' ] -- P571 represents the inception property .
for k, v in pairs(property) do
-- res = res .. ", " .. string.format("%s", v)
end
return # (pairs(property))
end
return p