![]() |
VOOZH | about |
Used in {{Story Mode recipe book}} and {{Story Mode recipe}}.
localp={} localfunctiontrim(x) localparts={ name='', amount='' } ifxthen localentered=mw.text.split(x,',') parts.name=mw.text.trim(entered[1]or'') parts.amount=mw.text.trim(entered[2]or'') end returnparts end localfunctionsimpleCalc(frame,index,key,class) returnframe:expandTemplate{ title="Simplecalc-hideifzero", args={ key, element='div', formula='not(y-'..(index-1)..')', starthidden=true, class=class } } end localfunctionslot(frame,args1,argsTitle,argsLink,suffix) localnamespace=mw.title.getCurrentTitle().namespace localitem locallink localtitle=argsTitleorargs1or'' if(namespace==10004ornamespace==10005)andargs1then ifsuffixthen item=args1 else item=args1..' SM' end link=argsLinkor('MCSM:'..args1) else item=args1or'' link=argsLinkor'' end returnframe:expandTemplate{ title="Slot", args={ item, link=link, title=title } } end localfunctiongrid(frame,args) localnamespace=mw.title.getCurrentTitle().namespace localcArgVals={'A1','B1','C1','A2','B2','C2','A3','B3','C3'} localtrimmed=trim(args.Output) localtrimmedName=trimmed.name localamount=trimmed.amount localOutput localOlink localOtitle=args.OtitleortrimmedName localresult={} localfunctionprnt(x) table.insert(result,x) end if(namespace==10004ornamespace==10005)andargs.Outputthen ifargs.Onosuffixthen Output=args.Output else Output=trimmedNameorargs.Output ifamount~=''then Output=Output..' SM'..','..amount else Output=Output..' SM' end end Olink=args.Olinkor('MCSM:'..trimmedName) else Output=args.Outputor'' Olink=args.OlinkortrimmedNameor'' end prnt('<table><tr><td>') fori,slotKeyinipairs(cArgVals)do prnt( slot( frame, args[slotKey], args[slotKey..'title'], args[slotKey..'link'], args[slotKey..'nosuffix'] ) ) ifi%3==0andi~=#cArgValsthen prnt('<br>') end end prnt('</td><td>[[File:Grid layout arrow (deep cream).png|link=]]</td><td class="dark-font-color">') prnt( frame:expandTemplate{ title="Slot", args={ Output, link=Olink, title=Otitle, class='invslot-large' } } ) prnt('</td></tr></table>') returntable.concat(result) end functionp.main(frame) localpageName=mw.title.getCurrentTitle().text localnamespace=mw.title.getCurrentTitle().namespace localargs=require('Module:ProcessArgs').norm(frame:getParent().args) localtitles={args['title']} localresult={} localfunctionprnt(x) table.insert(result,x) end localtrimmed=trim(args.Output).name prnt('<div style="overflow: hidden;"><div class="storymode-recipe-bg"><div class="storymode-recipe-name">') ifargs.Outputthen locallink if(namespace==10004ornamespace==10005)then ifargs.titlethen ifargs.titlelinkthen link='MCSM:'..args.titlelink..'|'..args.title else link='MCSM:'..args.title..'|'..args.title end else link='MCSM:'..trimmed..'|'..trimmed end else link=args.titleortrimmed end prnt('[['..link..']]') elseifnotargs.Outputandtitlesthen localfirstLink if(namespace==10004ornamespace==10005)then firstLink='[[MCSM:'..args.title..'|'..args.title..']]' elseifnotargs.titlethen firstLink='' else firstLink='[['..args.title..']]' end prnt(frame:expandTemplate{ title="Simplecalc-hideifzero", args={ firstLink, element='div', formula='not(y-0)' } }) forcount=2,20do localindex='title'..count ifargs[index]~='-'andargs[index]~=nilthen table.insert(titles,args[index]) end end fori=2,#titlesdo if(namespace==10004ornamespace==10005)then link='[[MCSM:'..titles[i]..'|'..titles[i]..']]' else link='[['..titles[i]..']]' end prnt(simpleCalc(frame,i,link)) end end prnt('</div><div class="storymode-recipe-grid-output"><div class="storymode-recipe-slot dark-font-color">') localrecipes={} ifargs.recipe1then forcount=1,20do localindex='recipe'..count ifargs[index]~='-'andargs[index]~=nilthen table.insert(recipes,args[index]) end end prnt(frame:expandTemplate{ title="Simplecalc-hideifzero", args={ args.recipe1, element='div', formula='not(y-0)', class='storymode-recipe-slot' } }) fori=2,#recipesdo prnt('<div>'..simpleCalc(frame,i,recipes[i],'storymode-recipe-slot')..'</div>') end else prnt(grid(frame,args)) end prnt('</div></div>') if#recipes>1then prnt('<div class="nomobile storymode-recipe-buttons">') prnt(frame:expandTemplate{ title='Simplecalc button', args={ id='buttoncount', ['type']='plain', weight='normal', contents='', ['for']='y', class='storymode-recipe-button-left', formula='min(max(y-1, 0), ('..#recipes..'-1))' } }) prnt(frame:expandTemplate{ title='Simplecalc button', args={ id='buttoncount2', ['type']='plain', weight='normal', contents='', ['for']='y', class='storymode-recipe-button-right', formula='min(max(y+1, 0), ('..#recipes..'-1))' } }) prnt('</div>') prnt('<div class="mobileonly storymode-recipe-buttons-mobile">') prnt(frame:expandTemplate{ title='Simplecalc button', args={ id='buttoncountmobile', ['type']='plain', weight='normal', contents='', ['for']='y', class='storymode-recipe-button-left', formula='min(max(y-1, 0), ('..#recipes..'-1))' } }) prnt(frame:expandTemplate{ title='Simplecalc button', args={ id='buttoncountmobile2', ['type']='plain', weight='normal', contents='', ['for']='y', class='storymode-recipe-button-right', formula='min(max(y+1, 0), ('..#recipes..'-1))' } }) prnt(frame:expandTemplate{ title='simplecalc', args={ ['type']='hidden', id='y', default=0 } }) prnt('</div>') end prnt('</div></div>') returntable.concat(result) end functionp.grid(frame) localargs=require('Module:ProcessArgs').norm(frame:getParent().args) returngrid(frame,args) end returnp