Modulo:DTGenerico: differenze tra le versioni
Da Wikitrek.
mNessun oggetto della modifica |
New loop to identify root class |
||
| (16 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 | ||
RootInstanceQ = | --Initial setting to calculate the root class of the item | ||
if | RootInstanceQ = InstanceQ | ||
-- | --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') | |||
if InstanceQ == "Q876" or InstanceQ == "Q78" or InstanceQ == "Q890" then | 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 InstanceQ == "Q876" or InstanceQ == "Q78" or InstanceQ == "Q890" then | |||
--Spaceship or starship | --Spaceship or starship | ||
mw.smw.set("Nome=" .. ShipNameCore(PageName)) | mw.smw.set("Nome=" .. ShipNameCore(PageName)) | ||
end | end | ||
else | else | ||
-- START Unspecified Property | -- START Unspecified Property | ||