Modulo:DTGenerico: differenze tra le versioni
Da Wikitrek.
mNessun oggetto della modifica |
New loop to identify root class |
||
| (22 versioni intermedie di uno stesso utente non sono mostrate) | |||
| Riga 89: | Riga 89: | ||
local ItemQ = mw.wikibase.getEntityIdForCurrentPage() | local ItemQ = mw.wikibase.getEntityIdForCurrentPage() | ||
local InstanceQ | local InstanceQ | ||
local RootInstanceQ | |||
local IsEpisode = false | local IsEpisode = false | ||
local OperatorName = "" | local OperatorName = "" | ||
| Riga 220: | 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 | |||
if InstanceQ == "Q876" or InstanceQ == "Q78" or InstanceQ == "Q890" then | 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 | |||
RootInstance = mw.wikibase.getLabelByLang(RootInstanceQ, 'it') | |||
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 | ||