Module:Sandbox/Tom.Reding/Tools
Appearance
Usage
- General syntax:
{{#invoke:Sandbox/Tom.Reding|function_name|parameter}}
getSDs
{{#invoke:Sandbox/Tom.Reding/Tools|getSDs|Carl Linnaeus}}
→ Script error: The function "getSDs" does not exist.
instanceOfs
{{#invoke:Sandbox/Tom.Reding/Tools|instanceOfs|Coelacanth}}
→ Script error: The function "instanceOfs" does not exist.
istaxon
{{#invoke:Sandbox/Tom.Reding/Tools|istaxon|Coelacanth}}
→ Lua error at line 14: attempt to call field '_entityid' (a nil value).{{#invoke:Sandbox/Tom.Reding/Tools|istaxon|Douglas Adams}}
→ Lua error at line 14: attempt to call field '_entityid' (a nil value).{{#invoke:Sandbox/Tom.Reding/Tools|istaxon|Universe}}
→ Lua error at line 14: attempt to call field '_entityid' (a nil value).
local p = {}
local function copyTable(inTable)
if type(inTable) ~= 'table' then return inTable end
local outTable = setmetatable({}, getmetatable(inTable))
for key, value in pairs (inTable) do outTable[copyTable(key)] = copyTable(value) end
return outTable
end
function p.istaxon(frame)
local resolve = require( 'Module:ResolveEntityId' )
local parentArgs = copyTable(frame:getParent().args)
local title = mw.getCurrentFrame():getParent().args[1]
local qid = resolve._entityid(frame, title)
local item = mw.wikibase.getEntity(qid)
local acceptable = {
['Q16521'] = 'taxon',
['Q310890'] = 'monotypic taxon',
['Q2568288'] = 'ichnotaxon',
['Q23038290'] = 'fossil taxon',
['Q47487597'] = 'monotypic fossil taxon',
}
if item then
for _, instanceOfState in pairs ( currentItem:getBestStatements('P31') ) do --instance of
local instanceOf = instanceOfState.mainsnak.datavalue.value.id
if acceptable[instanceOf] then
return title .. ' == taxon'
end
end
else
return title .. ': Wikidata item not found'
end
end
return p