Module:Sandbox

From Minecraft JE Data
Revision as of 00:32, 9 July 2022 by Bayugoon (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Sandbox/doc

local p = {};

function p.test(frame)
	local id = frame.args.id;
	local label = mw.wikibase.getLabel(id);
	
	local entity_type = mw.ustring.sub(id, 1, 1)
	
	local link
	
	if entity_type == "Q" then
		link = "Item:"..id
	elseif entity_type == "P" then
		link = "Property:"..id
	else
		link = "Special:EntityData/"..id
	end
	
	return "[["..link.."|"..label.." ".."("..id..")".."]]"
end

function p.test_resource_location(frame)
	local id = frame.args.id;
	
	return mw.wikibase.getEntity(id):formatPropertyValues('P4')['value'];
end

return p;