Module:Is instance and Module:Is instance/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
MusikBot II (talk | contribs) m Changed protection settings for "Module:Is instance": High-risk template or module: 8007 transclusions (more info) ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite)) |
make callable from module |
||
Line 1: | Line 1: | ||
local p = {}; |
local p = {}; |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
for i,statement in ipairs(subclasses) do -- loop through items at next depth |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
local args = frame.args |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
qid = mw.wikibase.getEntityIdForCurrentPage() |
qid = mw.wikibase.getEntityIdForCurrentPage() |
||
end |
end |
||
Line 37: | Line 11: | ||
return 0 |
return 0 |
||
end |
end |
||
checklist = {{qid}} |
local checklist,depth,maxdepth,isInstance = {{qid}},0,nil,false |
||
if args.maxdepth then |
|||
⚫ | |||
if md then |
|||
⚫ | |||
else |
else |
||
maxdepth = 5 |
maxdepth = 5 |
||
end |
end |
||
local function checklayer(depth) -- check subclasses of items at current depth |
|||
⚫ | |||
isInstance = false -- assume false until match found |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
while not isInstance and depth<maxdepth do |
while not isInstance and depth<maxdepth do |
||
depth = depth+1 |
depth = depth+1 |
||
Line 54: | Line 49: | ||
end |
end |
||
return depth -- return depth that item was found |
return depth -- return depth that item was found |
||
⚫ | |||
function p.main(frame) |
|||
return p._main(frame.args) |
|||
end |
end |
||