![]() |
VOOZH | about |
{{SoundTable}} instead.This module implements {{Sound table}}.
This module should not be invoked; {{Sound table}} should be called. See template documentation for more information.
localp={} localemptyevent=[=[''None''​<ref group="sound" name="emptyevent">Empty events do not have this parameter set.</ref>]=] localnosubtitle=[=[''None''​<ref group="sound" name="nosubtitle">[https://bugs.mojang.com/issues/?jql=project%20%3D%20MC%20AND%20resolution%20%3D%20Unresolved%20AND%20text%20~%20%22sound%20missing%22 Reports on Mojira].</ref>]=] localfunctionvardefine(f,name,value) f:callParserFunction('#vardefine',name,value) end localfunctionvar(f,name,defaultvalue) localresult=f:callParserFunction('#var',name,defaultvalue) ifresult==''then returnnil end returnresult end localcurNs=mw.title.getCurrentTitle().namespace localfunctionaddCategory(nocat,value,categoryName) if(curNs==0)or(curNs==10)or(curNs==10000)or(curNs==10002)or(curNs==10004)and(notnocat)then localcategory=[=[[[Category:Pages missing ]=]..categoryName..[=[]]]=] value=value..category end returnvalue end functionp.table(f) localargs=f iff==mw.getCurrentFrame()then args=require('Module:ProcessArgs').norm() else f=mw.getCurrentFrame() end localparent=f:getParent()orf localresult='' localjson={} localincludeHeader=notvar(parent,'soundstable') ifincludeHeaderthen vardefine(parent,'soundstable',1) ifargs.nocatthen vardefine(parent,'nocat',1) end localjava=false localbedrock=false localdungeons=false locallegends=false localhistorical=false localsimple=false vardefine(parent,'java','') vardefine(parent,'bedrock','') vardefine(parent,'dungeons','') vardefine(parent,'legends','') vardefine(parent,'historical','') vardefine(parent,'simple','') ifargs.type=='bedrock'then vardefine(parent,'bedrock',1) bedrock=true vardefine(parent,'tabletype','Bedrock') elseifargs.type=='dungeons'then vardefine(parent,'dungeons',1) dungeons=true vardefine(parent,'tabletype','Dungeons') elseifargs.type=='legends'then vardefine(parent,'legends',1) legends=true vardefine(parent,'tabletype','Legends') elseifargs.type=='historical'then vardefine(parent,'historical',1) historical=true vardefine(parent,'tabletype','historical') elseifargs.type=='simple'then vardefine(parent,'simple',1) simple=true vardefine(parent,'tabletype','simple') else vardefine(parent,'java',1) java=true vardefine(parent,'tabletype','Java') end localtableheader iflegendsorargs.forcecollapsedthen tableheader=[=[<table class="wikitable collapsible collapsed">]=] else tableheader=[=[<table class="wikitable collapsible expanded">]=] end result=result..tableheader end ifvar(parent,'rowspancooldown')then iftonumber(var(parent,'rowspancooldown'))>0then vardefine(parent,'rowspancooldown',var(parent,'rowspancooldown')-1) else vardefine(parent,'_sounds','') end end ifargs.rowspanthen vardefine(parent,'rowspancooldown',tonumber(args.rowspan)) end -- Header variables localnocat=var(parent,'nocat') localjava=var(parent,'java') localbedrock=var(parent,'bedrock') localdungeons=var(parent,'dungeons') locallegends=var(parent,'legends') localhistorical=var(parent,'historical') localsimple=var(parent,'simple') localtotalcolumns=0 localincludeSound=false localincludeSubtitles=false localincludeSource=false localincludeDescription=false localincludeId=false localincludeTranslationKey=false localincludeVolume=false localincludePitch=false localincludeAttenuationDistance=false ifjavathen totalcolumns=9 includeSound=true includeSubtitles=true includeSource=true includeDescription=true includeId=true includeTranslationKey=true includeVolume=true includePitch=true includeAttenuationDistance=true elseifbedrockthen totalcolumns=6 includeSound=true includeSource=true includeDescription=true includeId=true includeVolume=true includePitch=true elseifdungeonsthen totalcolumns=3 includeSound=true includeDescription=true includeId=true elseiflegendsthen totalcolumns=3 includeSound=true includeDescription=true includeId=true elseifhistoricalthen totalcolumns=7 includeSound=true includeSource=true includeDescription=true includeId=true includeVolume=true includePitch=true includeAttenuationDistance=true elseifsimplethen totalcolumns=2 includeSound=true includeDescription=true end json.java=java json.bedrock=bedrock json.dungeons=dungeons json.legends=legends json.historical=historical ifincludeHeaderthen localtitlerow=[=[<tr><th colspan=]=]..tostring(totalcolumns)..[=[>]=] ifargs.templatepagethen titlerow=titlerow..[=[<div class="navbox-navbar">]=]..parent:expandTemplate{title='Navbar',args={args.templatepage,mini="1"}}..[=[</div>]=] end titlerow=titlerow..(args.titleor[=[Sounds]=])..[=[</th></tr>]=] localheaderrow=mw.html.create('tr') localheadings={} ifincludeSoundthen table.insert(headings,'Sound') end ifincludeSubtitlesthen table.insert(headings,'[[Subtitles]]') end ifincludeSourcethen table.insert(headings,parent:expandTemplate{title='tooltip',args={'Source','The category this sound falls into; what volume slider controls this sound in the Music and Sounds menu.'}}) end ifincludeDescriptionthen table.insert(headings,parent:expandTemplate{title='tooltip',args={'Description','When the game calls this sound event.'}}) end ifincludeIdthen table.insert(headings,'[[Identifier]]') end ifincludeTranslationKeythen table.insert(headings,'Translation key') end ifincludeVolumethen table.insert(headings,'Volume') end ifincludePitchthen table.insert(headings,'Pitch') end ifincludeAttenuationDistancethen table.insert(headings,'Attenuation<br>distance') end fori,headerinipairs(headings)do headerrow :tag('th') :wikitext(header) end result=result..titlerow..tostring(headerrow) end localcells={} localrowspans={} ifincludeSoundthen ifargs.rowspanorvar(parent,'rowspancooldown')==nilortonumber(var(parent,'rowspancooldown'))<=0then localsound='' ifargs.sound=='-'then sound=[=[''None'']=] json.sounds='none' ifargs.rowspanthen vardefine(parent,'_sounds','none') end elseifargs.sound==nilthen sound=addCategory(nocat,'?','sounds') else localsounds={args.sound} forcount=2,20do localindex='sound'..count ifargs[index]then table.insert(sounds,args[index]) end end -- Use html instead of {{sound}} to avoid the #while in the template fori,soundarginipairs(sounds)do sound=sound.."<span class=\"sound\"><span class=\"sound-title\"></span>[[File:"..soundarg.."|class=sound-audio]]</span>" end json.sounds=sounds ifargs.rowspanthen vardefine(parent,'_sounds',table.concat(sounds,'&')) end end table.insert(cells,sound) table.insert(rowspans,args.rowspan) else json.sounds=mw.text.split(var(parent,'_sounds'),'&') end end ifincludeSubtitlesthen localsubtitle=args.subtitle ifargs.subtitle=='-'then subtitle=parent:preprocess(nosubtitle) elseifargs.sound=='-'andargs.subtitle==nilthen subtitle=parent:preprocess(emptyevent) elseifargs.translationkey=='-'then localcontent=parent:expandTemplate{title='bug',args={args.subtitle}} subtitle=[=[''None'']=]..'​'..parent:extensionTag('ref','​'..content..'​',{group='sound',name='bug'..args.subtitle})..'​' elseifargs.subtitle~=nilthen subtitle='​'..args.subtitle else subtitle='​'..addCategory(nocat,'?','subtitles') end table.insert(cells,subtitle) table.insert(rowspans,1) json.subtitle=subtitle end ifincludeSourcethen localsource=addCategory(nocat,'?','sound source') ifargs.overridesourcethen source=args.source elseifargs.source=='Master Volume'orargs.source=='master'then source='Master Volume' elseifargs.source=='Music'orargs.source=='music'then source='Music' elseifargs.source=='Jukebox/Note Blocks'orargs.source=='record'then source='Jukebox/Note Blocks' elseifargs.source=='Weather'orargs.source=='weather'then source='Weather' elseifargs.source=='Hostile Creatures'orargs.source=='hostile'then source='Hostile Creatures' elseifargs.source=='Friendly Creatures'orargs.source=='neutral'then source='Friendly Creatures' elseifargs.source=='Players'orargs.source=='player'then source='Players' elseifargs.source=='Blocks'orargs.source=='block'then source='Blocks' elseifargs.source=='Ambient/Environment'orargs.source=='ambient'then source='Ambient/Environment' elseifargs.source=='Voice/Speech'orargs.source=='voice'then source='Voice/Speech' elseifargs.source=='Sound'orargs.source=='sound'then source='Sound' elseifargs.source=='Entity-Dependent'orargs.source=='dependent'then source="''[[Sound#Entity-dependent categories|Entity-Dependent]]''" elseifargs.source=='None'orargs.source=='none'orargs.source=='-'then source="''None''" end table.insert(cells,source) table.insert(rowspans,1) json.source=source end ifincludeDescriptionthen localdesc=args.descriptionoraddCategory(nocat,'?','sound description') table.insert(cells,desc) table.insert(rowspans,1) json.desc=desc end ifincludeIdthen localid ifargs.idthen id=[=[<code>]=]..args.id..[=[</code>]=] id=id:gsub('%.','<wbr/>.') json.id=args.id else id=addCategory(nocat,'?','sound ID') end ifargs.idnotethen id=id..'​'..args.idnote..'​' json.idnote=args.idnote end table.insert(cells,id) table.insert(rowspans,1) end ifincludeTranslationKeythen localtranslationkey ifargs.sound=='-'andargs.translationkey==nilthen translationkey=parent:preprocess(emptyevent) elseifargs.subtitle=='-'then translationkey=parent:preprocess(nosubtitle) elseifargs.translationkey=='-'then localcontent=parent:expandTemplate{title='bug',args={args.subtitle}} translationkey=[=[''None'']=]..'​'..parent:extensionTag('ref','​'..content..'​',{group='sound',name='bug'..args.subtitle})..'​' elseifargs.translationkey=="''None''"orargs.translationkey=="None"then translationkey=[=[''None''​]=] json.translationkey=translationkey elseifargs.translationkey~=nilthen translationkey=[=[<code>]=]..args.translationkey..[=[</code>]=]..'​' translationkey=translationkey:gsub('%.','<wbr/>.') json.translationkey=args.translationkey else translationkey='​'..addCategory(nocat,'?','subtitle key') end ifargs.translationkeynotethen translationkey=translationkey..'​'..args.translationkeynote..'​' json.translationkeynote=args.translationkeynote end table.insert(cells,translationkey) table.insert(rowspans,1) end ifincludeVolumethen table.insert(cells,args.volumeoraddCategory(nocat,'?','sound volume')) table.insert(rowspans,1) json.volume=args.volume end ifincludePitchthen table.insert(cells,args.pitchoraddCategory(nocat,'?','sound pitch')) table.insert(rowspans,1) json.pitch=args.pitch end ifincludeAttenuationDistancethen table.insert(cells,args.distanceoraddCategory(nocat,'?','sound attenuation distance')) table.insert(rowspans,1) json.distance=args.distance end localrow=mw.html.create('tr') local_td fori,cellinipairs(cells)do _td=row :tag('td') :attr('rowspan',rowspans[i]) :wikitext(cell) end local_json={} fork,vinpairs(json)do iftype(v)=='string'then ifnotv:find('[[Category:Pages missing ',0,true)then _json[k]=v end else _json[k]=v end end _td:wikitext(require('Module:NiceJSON').wrap(_json,'pre','sound-json')) result=result..tostring(row) ifargs.footthen -- Reset the variables we used vardefine(parent,'soundstable','') vardefine(parent,'nocat','') vardefine(parent,'bedrock','') vardefine(parent,'dungeons','') vardefine(parent,'historical','') vardefine(parent,'rowspancooldown',0) -- Add table ending result=result..[=[</table>[[Category:Pages with sound tables]][[Category:Pages with ]=]..var(parent,'tabletype')..[=[ sound tables]]]=]..parent:expandTemplate{title='notelist',args={'sound'}} vardefine(parent,'tabletype','') end returntostring(result) end returnp