Module:Sandbox/Fewfre

-- Initially taken from: https://minecraft.gamepedia.com/Module:Inventory_slot

local p = {}

function p.test return 'hi' end

function p.test2 require(Module:Item) return 'hi2' end

function p.test3 local item = require(Module:Item) return 'hi3 - '..item._sellPrice('wheat') end

local loader = require('Module:Loader') local getArgs = require('Module:Arguments').getArgs local string, table, yesno, mctxt, rarity = loader.require('String', 'Table', 'Yesno', 'Mctxt', 'RarityTier') local link, skillname = loader.require('Link', 'Skillname') local enchData = loader.require('Enchantment/Data')

--- -- Generates multiple rows needed for a single potion on Potions page -- Invoked by Template:PotionPageRow --- function p.enchantmentPageRow(frame) local args = getArgs(frame) local name = args[1] local nameNote = args['nameNote'] local desc = args['desc'] local unlock = args['unlock'] return p._enchantmentPageRow(name, nameNote, desc, unlock) end function p._enchantmentPageRow(enchantName, nameNote, desc, unlocks) local ench = enchData[enchantName] if not ench then return string._error('Invalid enchantment name \"' .. enchantName .. '\"') end -- Basic Row Data local introTable = mw.html.create('table'):addClass('wikitable') :css{ height="100%" } -- This and other 100% on lable elements below are required for 100% height to work inside the description cell local row1 = introTable:tag('tr'):css{ height="35px" } local temp = row1:attr{ id=enchantName }:addClass('article-row-main') -- max width added purely for stylistic reasons on wider table :tag('th'):attr{ colspan=2 }:css{ ['text-align']='left !important' } :tag('div'):css{ display='flex', gap='16px' } :tag('div') :wikitext( link.enchantmentsLink{ enchantName } ) :wikitext( nameNote ) :done if ench.req then -- note: parent div hasn't been `done` yet, so `temp` here is adding it to the parent div, not the row or cell - basically this just acts as a continuation temp:tag('span'):css{ flex=1, ['text-align']='right' } :tag('b'):wikitext(table.concat{ skillname.getSkillName{ 'enchanting', short=true }, ' Lvl: ' }):done :tag('span'):wikitext( ench.req ):css{ ['font-weight']='normal' }:done :done end temp:done :done local row2 = introTable:tag('tr'):addClass('article-row-bound'):css{ height='100%' }--100% height needed for cell contents to use 100% height :tag('td'):css{ ['text-align']='left' }:addClass('seperator-cell'):wikitext(desc or 'Unknown description'):done :done -- Level data half of table / data sub table local dataTable = mw.html.create('table'):addClass('wikitable centertext') local dataRow1 = dataTable:tag('tr'):css{ height="35px" } local dataRow2 = dataTable:tag('tr') local dataRow3 = dataTable:tag('tr'):css{ ['line-height']='1.3' } -- Add level data to rows local numDataColumns = ench.max; local lastLevelWithItem = 0 for i = 1, ench.max do		dataRow1:tag('th'):wikitext( rarity._link(ench.rarity[i], ench.cost[i] and string.makeTitle(string._toRoman(i), table.concat{ 'EXP Cost: ', ench.cost[i] }) or string._toRoman(i)) ):css{ width=(100/numDataColumns)..'%' } -- potions can have ingredients, level-specific stats, or both! local singleDataRow = not (ench.vars and unlocks) if ench.vars then local levelVars = {} for j, varList in pairs(ench.vars) do				levelVars[#levelVars+1] = varList[i] end (singleDataRow and dataRow2 or dataRow3):tag('td'):addClass('seperator-cell') :wikitext( table.concat(levelVars, ' ') )		end -- if unlocks then -- 	local ingredient = nil -- 	if unlocks[i] then -- 		ingredient = slot{ unlocks[i] } -- 		lastLevelWithItem = i		-- 	elseif unlocks[i..'text'] then -- 		ingredient = unlocks[i..'text'] -- 		lastLevelWithItem = i		-- 	else -- 		ingredient = potionPageRowLevelBoosters[i-lastLevelWithItem] -- 	end -- 	local cell = dataRow2:tag('td'):wikitext( ingredient or '?' ) -- 	if singleDataRow then -- 		cell:attr{ rowspan=2 } -- 	end -- end if not unlocks and not ench.vars then dataRow2:tag('td'):addClass('seperator-cell') :wikitext( ' '..string.blankCell ) :attr{ rowspan=2 } end end return table.concat{ tostring(introTable), tostring(dataTable) } end

return p