Modifica di
Modulo:Spawn table
Vai alla navigazione
Vai alla ricerca
Attenzione:
non hai effettuato l'accesso. Se effettuerai delle modifiche il tuo indirizzo IP sarà visibile pubblicamente. Se
accedi
o
crei un'utenza
, le tue modifiche saranno attribuite al tuo nome utente, insieme ad altri benefici.
Controllo anti-spam.
NON
riempirlo!
local p = {} local i18n = { processArgsModule = 'Modulo:ProcessArgs', entityLinkTemplate = 'CollegamentoEntità', editionsTemplate = 'Template:Edizioni', mobColumn = 'Creatura', chanceColumn = mw.getCurrentFrame():expandTemplate{title='Tooltip', args={'Possibilità di generazione', 'Possibilità di generarsi in relazione ad altre creature nelle categoria'}}, groupSizeColumn = mw.getCurrentFrame():expandTemplate{title='Tooltip', args={'Dimensione del gruppo', 'Numero di creature che il gioco tenta di generare ad ogni tentativo'}} } local spawnData = {} -- contains mob spawn info local groupArgs = { ['passive'] = 'Categoria passive', ['hostile'] = 'Categoria ostili', ['water'] = 'Categoria acquatica', ['watercreature'] = 'Categoria creature acquatiche', ['ambient'] = 'Categoria ambiente', ['waterambient'] = 'Categoria ambiente acquatico' } local hasNotes = false -- parses input arguments into spawnData table local function parseInput(args) for argName in pairs(groupArgs) do local groupArg = args[argName] if groupArg then local currentGroup = {} local totalWeight = 0 currentGroup.mobs = {} groupArg = groupArg .. '\n' -- allow last line to be matched like the rest -- parse input of group parameter for line in mw.ustring.gmatch(groupArg, '[^\r\n]+[\r\n]') do -- split on newline local parsedLine = {} for key, value in mw.ustring.gmatch(line, '([%a]+)%s*=%s*(.-)%s*[,\r\n]') do if value ~= '' then parsedLine[key:lower()] = value end end --parsedLine.mob = mw.ustring.match(line, '^%s*(.-)%s*,') parsedLine.note = mw.ustring.match(line, 'note=%s*(.-)%s*[\r\n]') local currentMob = {} -- convert weight to number; becomes nil if conversion fails if parsedLine.weight then weightNum = tonumber(parsedLine.weight) -- if converted to number successfully if weightNum then currentMob.weight = weightNum totalWeight = totalWeight + weightNum end end if parsedLine.size then currentMob.size = parsedLine.size end if parsedLine.note then hasNotes = true currentMob.note = parsedLine.note end if parsedLine.notename then currentMob.notename = parsedLine.notename end if parsedLine.mob then currentMob.mob = parsedLine.mob table.insert(currentGroup.mobs, currentMob) end end currentGroup.totalWeight = totalWeight spawnData[argName] = currentGroup end end end -- takes root <table> html object and adds table body using info in spawnData local function addTableBody(tableRoot, numberOfColumns) local frame = mw.getCurrentFrame() local groupNumber = 1 for groupArg, groupTable in pairs(spawnData) do local groupHeader = mw.html.create('tr') groupHeader:tag('th') :attr('colspan', numberOfColumns) :wikitext(groupArgs[groupArg]) tableRoot:node(groupHeader) for _, mobData in ipairs(groupTable.mobs) do local tableRow = mw.html.create('tr') local mobCellText = frame:expandTemplate{title=i18n.entityLinkTemplate, args={mobData.mob}} if mobData.note then mobCellText = mobCellText .. frame:extensionTag{name='ref', content=mobData.note, args={name=mobData.mob:lower(), group='note'}} elseif mobData.notename then mobCellText = mobCellText .. frame:extensionTag{name='ref', args={name=mobData.notename:lower(), group='note'}} end tableRow:tag('th') :css('text-align', 'left') :css('font-weight', 'normal') :wikitext(mobCellText) tableRow:tag('td') :css('text-align', 'center') :wikitext('<sup>' .. mobData.weight .. '</sup>⁄<sub>' .. groupTable.totalWeight .. '</sub>') tableRow:tag('td') :css('text-align', 'center') :wikitext(mobData.size) tableRoot:node(tableRow) end end end -- function called from template function p.mobSpawnTable(frame) local args = frame if frame == mw.getCurrentFrame() then args = require(i18n.processArgsModule).merge( true ) else frame = mw.getCurrentFrame() end parseInput(args) local columns = {i18n.mobColumn, i18n.chanceColumn, i18n.groupSizeColumn} -- local biome = string.lower(args.biome or mw.title.getCurrentTitle().text) -- may be useful if Cargo functionality is added local tableRoot = mw.html.create('table'):attr('class', 'wikitable') local titleStr = args.title if args.edition then local editionStr = frame:expandTemplate{title=i18n.editionsTemplate, args={args.edition}} if titleStr then titleStr = titleStr .. ' in ' .. editionStr else titleStr = 'In ' .. editionStr end end if titleStr then tableRoot :tag('caption') :wikitext(titleStr) end local colHeaders = mw.html.create('tr') for _, value in pairs(columns) do colHeaders:tag('th'):wikitext(value) end tableRoot:node(colHeaders) addTableBody(tableRoot, #columns) local outputWikitext = tostring(tableRoot) if hasNotes then outputWikitext = outputWikitext .. '\n\n' .. frame:extensionTag{name='references', args={group='note'}} end return outputWikitext end return p
Oggetto:
Per favore tieni presente che tutti i contributi a Minecraft Wiki si considerano pubblicati nei termini d'uso della licenza CC BY-NC-SA 3.0 (vedi
Minecraft Wiki:Copyright
per maggiori dettagli). Se non desideri che i tuoi testi possano essere modificati e ridistribuiti da chiunque senza alcuna limitazione, non inviarli qui.
Inviando il testo dichiari inoltre, sotto tua responsabilità, che è stato scritto da te personalmente oppure è stato copiato da una fonte di pubblico dominio o similarmente libera.
Non inviare materiale protetto da copyright senza autorizzazione!
Annulla
Guida
(si apre in una nuova finestra)
Anteprima di una pagina con questo template
Nota che:
Se non vuoi che i tuoi interventi vengano modificati senza pietà o redistribuiti da altri, non inviarli.
Sulle pagine di discussione,
firma il tuo intervento
digitando quattro tilde (
~~~~
).
Usa il pulsante
Visualizza anteprima
prima di salvare i cambiamenti per ridurre il numero di modifiche mostrato nella lista delle
ultime modifiche
.
Template utilizzati in questa pagina:
Template:Testata documentazione
(
modifica
)
Template:Tl
(
modifica
)
Modulo:Documentazione
(
modifica
)
Modulo:ProcessArgs
(
modifica
)
Modulo:Spawn table/doc
(
modifica
)
Questa pagina appartiene a una categoria nascosta:
Categoria:Pages using DynamicPageList3 dplvar parser function
Menu di navigazione
Strumenti personali
Accesso non effettuato
discussioni
contributi
registrati
entra
Namespace
Modulo
Discussione
English
Visite
Leggi
Modifica sorgente
Cronologia
Altro
Aggiorna
Ricerca
Navigazione
Come aiutare
Ultime modifiche
Una pagina a caso
in Minecraft
in Dungeons
in Legends
in Earth
in Story Mode
Discord del Wiki
Comunità del wiki
Portale comunità
Progetti
Regole del wiki
Guida di stile
Notabilità
Sandbox
Bacheca amministratori
Pagina dei direttori
Giochi
Minecraft
Minecraft Dungeons
Minecraft Legends
Minecraft Earth
Minecraft: Story Mode
Ultime versioni
Java Edition
Ultima: 1.21.4
Bedrock Edition
Ultima: 1.21.51
Anteprima: 1.21.60.24
In arrivo: 1.21.60
Pagine utili
Commercio
Distillazione
Incantamento
Mob
Blocchi
Oggetti
Fabbricazione
Cottura
Lezioni
Pacchetti di risorse
Circuito di redstone
Pagine utili
Armi
Incantamento
Armatura
Artefatti
Missioni
Pagine utili
Unità amichevoli
Piglin
Risorse
Biomi
Strutture
Lost Legends
Strumenti
Puntano qui
Modifiche correlate
Pagine speciali
Informazioni pagina