<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://moasspedia.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AIs_instance</id>
	<title>Module:Is instance - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://moasspedia.org/w/index.php?action=history&amp;feed=atom&amp;title=Module%3AIs_instance"/>
	<link rel="alternate" type="text/html" href="https://moasspedia.org/w/index.php?title=Module:Is_instance&amp;action=history"/>
	<updated>2026-04-17T19:55:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.2</generator>
	<entry>
		<id>https://moasspedia.org/w/index.php?title=Module:Is_instance&amp;diff=2124&amp;oldid=prev</id>
		<title>Wikipedia&gt;MSGJ: check that snaktype=value</title>
		<link rel="alternate" type="text/html" href="https://moasspedia.org/w/index.php?title=Module:Is_instance&amp;diff=2124&amp;oldid=prev"/>
		<updated>2022-04-02T21:41:18Z</updated>

		<summary type="html">&lt;p&gt;check that snaktype=value&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {};&lt;br /&gt;
&lt;br /&gt;
local function checklayer(depth) -- check subclasses of items at current depth&lt;br /&gt;
	checklist[depth+1] = {} -- setup next layer of table&lt;br /&gt;
	local j = 0&lt;br /&gt;
	for j = 1,#checklist[depth] do -- loop over items at current depth&lt;br /&gt;
		local property&lt;br /&gt;
		if depth == 1 then&lt;br /&gt;
			property = &amp;quot;P31&amp;quot; -- use P31 for depth 1&lt;br /&gt;
		else&lt;br /&gt;
			property = &amp;quot;P279&amp;quot; -- use P279 for depths 2+&lt;br /&gt;
		end&lt;br /&gt;
		local subclasses = mw.wikibase.getBestStatements(checklist[depth][j],property) -- get P31 or P279 statements&lt;br /&gt;
		for i,statement in ipairs(subclasses) do -- loop through items at next depth&lt;br /&gt;
			if statement.mainsnak.snaktype == &amp;#039;value&amp;#039; then&lt;br /&gt;
				local newitem = statement.mainsnak.datavalue.value.id&lt;br /&gt;
				if newitem == value then&lt;br /&gt;
					isInstance = true&lt;br /&gt;
				else&lt;br /&gt;
					checklist[depth+1][#checklist[depth+1]+1] = newitem -- add item to next depth of checklist table&lt;br /&gt;
				end&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return isInstance&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	local args = frame.args&lt;br /&gt;
	local pargs = frame:getParent().args&lt;br /&gt;
	value = args.value or pargs.value&lt;br /&gt;
	local qid = args.qid or pargs.qid or &amp;quot;&amp;quot;&lt;br /&gt;
	if qid == &amp;quot;&amp;quot; then&lt;br /&gt;
		qid = mw.wikibase.getEntityIdForCurrentPage()&lt;br /&gt;
	end&lt;br /&gt;
	if not qid then&lt;br /&gt;
		return 0&lt;br /&gt;
	end&lt;br /&gt;
	checklist = {{qid}}&lt;br /&gt;
	local md = args.maxdepth or pargs.maxdepth&lt;br /&gt;
	if md then&lt;br /&gt;
		maxdepth = tonumber(md)&lt;br /&gt;
	else&lt;br /&gt;
		maxdepth = 5&lt;br /&gt;
	end&lt;br /&gt;
	depth = 0 -- current depth&lt;br /&gt;
	isInstance = false -- assume false until match found&lt;br /&gt;
	while not isInstance and depth&amp;lt;maxdepth do&lt;br /&gt;
		depth = depth+1&lt;br /&gt;
		checklayer(depth)&lt;br /&gt;
	end&lt;br /&gt;
	if not isInstance then&lt;br /&gt;
		depth = 0 -- indicates not isInstance&lt;br /&gt;
	end&lt;br /&gt;
	return depth -- return depth that item was found&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Wikipedia&gt;MSGJ</name></author>
	</entry>
</feed>