Module:Sandbox/Underlying lk/Wikidatacoordtest

--http://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q1590213&format=jsonfm

-- Module:Wikibase local p = {} -- Return the item ID of the item linked to the current page. function p.id(frame) if not mw.wikibase then return "wikibase module not found" end entity = mw.wikibase.getEntity if entity == nil then return "(no item connected)" end return entity.claims['P281'][0].mainsnak.datavalue.value end function p.tablew(frame) t2 = mw.wikibase.getEntity.claims claimsList = {} local num = frame.args[1] local num = tonumber(num) for k, v in pairs(t2) do		if k == "p281" then k = v[0].mainsnak.datavalue.value end table.insert(claimsList, k)	end return claimsList[num] end

function p.tableview(frame) --	-- returns the value of the property P281 having 1162282 as qualifier t2 = mw.wikibase.getEntity.claims[frame.args[1]] claimsList = {} for k,v in pairs(t2) do		if v.qualifiers then --this instance of P281 --has a qualifier qualifiersTable = v.qualifiers for key, qualifier in pairs(qualifiersTable) do				if qualifier[0].datavalue.value["numeric-id"] then code = qualifier[0].datavalue.value["numeric-id"] if code == tonumber(frame.args[2]) then code = v.mainsnak.datavalue.value table.insert(claimsList, code) end end end end end return claimsList[1] end

function p.tabee(frame) t2 = mw.wikibase.getEntity.claims['p281'] claimsList = {} local num = frame.args[1] local num = tonumber(num) for k,v in pairs(t2) do		k = v.mainsnak.datavalue.value k = v.references[0].snaks["P248"][0].datavalue.value['numeric-id'] table.insert(claimsList, k)	end return claimsList[num] end return p