![]() |
VOOZH | about |
This module implements
{{Generic inventory}}{{Additions table}}{{Container}}{{Hopper}}{{Dispenser}}For other interfaces and full Survival Inventory, {{Inventory}} is a temporary alternative
localp={} localincludeInv=false --[[ Adds inventory to containers. ]] localfunctionaddInventory(args) localhotbar={} localj=0 whilej<9do table.insert(hotbar,require("Module:Inventory slot").slot{args['inv'..j+1]}) j=j+1 end localinventory={} locali=1 whilei<4do table.insert(inventory,'<span style="display: block;">') -- For each column (9 for each row) localj=0 whilej<9do table.insert(inventory,require("Module:Inventory slot").slot{args['inv'..(i*9)+j+1]}) j=j+1 end table.insert(inventory,'</span>') i=i+1 end return'<span style="position: absolute; bottom:159px; left: 8px; color: #3F3F3F; font-family: Minecraft; font-size: 16px;">Inventory</span><span style="position: absolute; bottom: 6px; left: 6px">'..table.concat(inventory)..'<span style="display:block; margin-top:8px">'..table.concat(hotbar)..'</span></span>' end --[[ Adds slots (the actual container) ]] localfunctionaddSlots(args) localslotargs={} localslots={} localrows -- Limit means it cannot go beyond defined set of number ifargs.typethen locali=1 rows=0 ifargs.type:lower()=='chest'or'ender-chest'or'shulker-box'or'barrel'then rows=3 end ifargs.type:lower()=='large-chest'then rows=6 end whilei<(rows*9)+1do slotargs[i]=args[i] i=i+1 end elseifargs.rowsthen rows=tonumber(args.rows) locali=1 whilei<(rows*9)+1do slotargs[i]=args[i] i=i+1 end else locali=1 whiletruedo ifargs[i]==nilorargs[i]==''then break; else slotargs[i]=args[i] end i=i+1 end -- Calculate rows rows=tonumber(math.floor((8+#slotargs)/9)) end -- For each row locali=0 whilei<rowsdo table.insert(slots,'<span style="display: block;">') -- For each column (9 for each row) localj=0-- args[1] whilej<9do table.insert(slots,require("Module:Inventory slot").slot{slotargs[(i*9)+j+1]}) j=j+1 end table.insert(slots,'</span>') i=i+1 end returnslots,rows end functionp.hopper(f) localargs=f iff==mw.getCurrentFrame()then args=require('Module:ProcessArgs').merge(true) else f=mw.getCurrentFrame() end localtitle=args.titleor'Item Hopper' localslots={} locali=0 whilei<5do table.insert(slots,require("Module:Inventory slot").slot{args[i+1]}) i=i+1 end ifargs.forceinventorythenincludeInv=trueend locali=1 whilei<37do ifargs['inv'..i]==nilorargs['inv'..i]==''then else includeInv=true break end i=i+1 end localplayerInventory='' ifincludeInv==truethenplayerInventory=addInventory(args)end localtableheight=56 ifincludeInvthentableheight=tableheight+180end return'<div style="float:'..(args.alignor'')..'; clear:'..(args.alignor'')..'">'.. '<span class="mcui mcui-Inventory-border pixel-image" style="box-sizing: content-box;border-width: 8px;border-style: solid;border-radius: 0; background-clip: padding-box; width: 324px; height: '..tableheight..'px>'.. '<span style="display: block; color: #3F3F3F; font-family: Minecraft; font-size: 16px; text-align: left; margin-left: 2px; margin-top: -6px; overflow: hidden; text-overflow: ellipsis;" title="'..title..'">'..title..'</span>'.. '<span style="position: absolute; top: 30px; left: 78px;">'..table.concat(slots)..'</span>'..playerInventory..'</span></div>'.. '<div class="mobileonly"><div style="clear:both"></div></div>' end functionp.dispenser(f) localargs=f iff==mw.getCurrentFrame()then args=require('Module:ProcessArgs').merge(true) else f=mw.getCurrentFrame() end localtitle=args.titleor'Dispenser' localslots={} locali=0 whilei<3do table.insert(slots,'<span style="display: block;">'..require("Module:Inventory slot").slot{args[i+1]}..require("Module:Inventory slot").slot{args[i+2]}..require("Module:Inventory slot").slot{args[i+3]}..'</span>') i=i+1 end ifargs.forceinventorythenincludeInv=trueend i=1 whilei<37do ifargs['inv'..i]==nilorargs['inv'..i]==''then else includeInv=true break end i=i+1 end localplayerInventory='' ifincludeInv==truethenplayerInventory=addInventory(args)end localtableheight=128 ifincludeInvthentableheight=tableheight+180end return'<div style="float:'..(args.alignor'')..'; clear:'..(args.alignor'')..'">'.. '<span class="mcui mcui-Inventory-border pixel-image" style="box-sizing: content-box;border-width: 8px;border-style: solid;border-radius: 0; background-clip: padding-box; width: 324px; height: '..tableheight..'px>'.. '<span style="display: block; color: #3F3F3F; font-family: Minecraft; font-size: 16px; text-align: left; margin-left: 2px; margin-top: -6px; overflow: hidden; text-overflow: ellipsis;" title="'..title..'">'..title..'</span>'.. '<span style="position: absolute; top: 24px; left: 114px;">'..table.concat(slots)..'</span>'..playerInventory..'</span></div>'.. '<div class="mobileonly"><div style="clear:both"></div></div>' end functionp.container(f) localargs=f iff==mw.getCurrentFrame()then args=require('Module:ProcessArgs').merge(true) else f=mw.getCurrentFrame() end localtitle=args.titleorf:callParserFunction('ucfirst',string.gsub(args.type,'-',' ')) localslots,rows=addSlots(args) ifargs.forceinventorythenincludeInv=trueend locali=1 whilei<37do ifargs['inv'..i]==nilorargs['inv'..i]==''then else includeInv=true break end i=i+1 end localplayerInventory='' ifincludeInv==truethenplayerInventory=addInventory(args)end -- Compute height of the table localtableheight=rows*36+20 ifincludeInvthentableheight=tableheight+180end -- Return output return'<div style="float:'..(args.alignor'')..'; clear:'..(args.alignor'')..'">'.. '<span class="mcui mcui-Inventory-border pixel-image" style="box-sizing: content-box;border-width: 8px;border-style: solid;border-radius: 0; background-clip: padding-box; width: 324px; height: '..tableheight..'px>'.. '<span style="display: block; color: #3F3F3F; font-family: Minecraft; font-size: 16px; text-align: left; margin-left: 2px; margin-top: -6px; overflow: hidden; text-overflow: ellipsis;" title="'..title..'">'..title..'</span>'.. '<span style="position: absolute; top: 26px; left: 6px;">'..table.concat(slots)..'</span>'..playerInventory..'</span></div>'.. '<div class="mobileonly"><div style="clear:both"></div></div>' end functionp.additions(f) localargs=f iff==mw.getCurrentFrame()then args=require('Module:ProcessArgs').merge(true) else f=mw.getCurrentFrame() end localfunction_getVersionTitle() localeditions={ "Java Edition","Bedrock Edition","Pocket Edition","Minecraft Education","Education Edition","Xbox 360 Edition","PlayStation 3 Edition","PlayStation 4 Edition","PlayStation Vita Edition","Xbox One Edition","Console Edition" } for_,editioninpairs(editions)do iftostring(mw.title.getCurrentTitle()):match('^'..edition)then returnstring.sub( tostring(mw.title.getCurrentTitle()), string.len(edition)+2 ) end end return"" end localtitle=args.titleor_getVersionTitle() localheading="" iftitle==""then heading='Block and item additions' else heading=title..' block and item additions' end localslots,rows=addSlots(args) -- Compute height of the table localtableheight=rows*36+20 -- Return output localclear=' clear:'..(args.alignor'right')..';' ifargs.noclearthen clear='' end return'<div style="float:'..(args.alignor'right')..';'..clear..'">'.. '<span class="mcui mcui-Inventory-border pixel-image" style="box-sizing: content-box;border-width: 8px;border-style: solid;border-radius: 0; background-clip: padding-box; width: 324px; height: '..tableheight..'px>'.. '<span style="display: block; color: #3F3F3F; font-family: Minecraft; font-size: 16px; text-align: left; margin-left: 2px; margin-top: -6px; overflow: hidden; text-overflow: ellipsis;" title="'..heading..'">'..heading..'</span>'.. '<span style="position: absolute; top: 26px; left: 6px;">'..table.concat(slots)..'</span></span></div>'.. '<div class="mobileonly"><div style="clear:both"></div></div>' end functionp.main(f) -- Gets arguments localargs=f iff==mw.getCurrentFrame()then args=require('Module:ProcessArgs').merge(true) else f=mw.getCurrentFrame() end -- Title localtitle=args.titleor'' localslots,rows=addSlots(args) -- Compute height of the table localtableheight=rows*36 ifargs.titlethen tableheight=tableheight+20 end -- Return output return'<div style="float:'..(args.alignor'')..'; clear:'..(args.alignor'')..'">'.. '<span class="mcui mcui-Inventory-border pixel-image" style="box-sizing: content-box;border-width: 8px;border-style: solid;border-radius: 0; background-clip: padding-box; width: 324px; height: '..tableheight..'px>'.. '<span style="display: block; color: #3F3F3F; font-family: Minecraft; font-size: 16px; text-align: left; margin-left: 2px; margin-top: -6px; overflow: hidden; text-overflow: ellipsis;" title="'..title..'">'..title..'</span>'.. '<span style="position: absolute; top: 26px; left: 6px;">'..table.concat(slots)..'</span></span></div>'.. '<div class="mobileonly"><div style="clear:both"></div></div>' end returnp