68 602
contributi
(Routine to get the root instance of a given item) |
(New loop to identify root class) |
||
(5 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 221: | Riga 221: | ||
InstanceQ = Item.claims[Property][1].mainsnak.datavalue.value.id | InstanceQ = Item.claims[Property][1].mainsnak.datavalue.value.id | ||
--Initial setting to calculate the root class of the item | |||
RootInstanceQ = InstanceQ | |||
if | --Loop only if the element is not a Class itself | ||
-- | if RootInstanceQ ~= "Q47" then | ||
--Set a reasonable number of iteration to avoid infinite loop | |||
for i = 1, 15, 1 do | |||
local TempQ | |||
TempQ = mw.wikibase.getEntity(RootInstanceQ).claims["P14"][1].mainsnak.datavalue.value.id | |||
--If | |||
if TempQ == "Q47" then | |||
break | |||
else | |||
RootInstanceQ = TempQ | |||
end | |||
end | |||
end | end | ||
RootInstance = mw.wikibase.getLabelByLang(RootInstanceQ, 'it') | |||
mw.smw.set("Istanza radice=" .. RootInstance) | mw.smw.set("Istanza radice=" .. RootInstance) | ||
--If the item's root class is spaceship, then sets the name | |||
if RootInstance == "Astronave" or RootInstance == "Spaceship" then | if RootInstance == "Astronave" or RootInstance == "Spaceship" then | ||
--if InstanceQ == "Q876" or InstanceQ == "Q78" or InstanceQ == "Q890" then | --if InstanceQ == "Q876" or InstanceQ == "Q78" or InstanceQ == "Q890" then |