Module:Multiblock 2

local p = {}

p.multiblock = function(f) local args = f.args or f   if f == mw.getCurrentFrame then args = f:getParent.args else f = mw.getCurrentFrame end local alpha = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'} structure = {} local height = 0 for i, letter in ipairs(alpha) do if args[letter .. "A1"] ~= nil then --Good, another row structure[letter] = {} for i, j in ipairs(alpha) do if args[letter .. j .. 1] ~= nil then structure[letter][j] = {} for i = 1, 10 do --10 purely as a maximum, a 10x10 multiblock is way larger than would normally be sensible if args[letter .. j .. i] ~= nil then structure[letter][j][i] = args[letter .. j .. i]      					end end end end else if i ~= 1 then --mw.log("Ended at " .. alpha[i-1]) <- That's the height height = i-1 break --End of multiblock bits else return "Shorted" --Just give up ;)      		end       	end    end    --mw.logObject(structure)    local size = 0    if tableSize(structure) > 0 then    	for i, letter in ipairs(alpha) do    		if structure["A"][letter] ~= nil then --Relying on the fact that A is the right size, could also check the whole thing for uniformity    			local s = tableSize(structure["A"][letter])    			if (s > size) then    				size = s    			end			else				break			end		end	else		mw.log("A useless set of args was sent :|")		return "Shorted"	end	--mw.log("The size was " .. size)	 --There's no chance of this going wrong at all. EVERYTHING .	local test = {}	test[2] = (((size-1)*64)+32)	test[3] = (height*100)+15	local page = " " .. f:expandTemplate{title="Cg", args=test}	--local option = {{0},{-1,1},{-2,0,2},{-1,1},{0}} --temp solution until I'm more creative	for i, outter in ipairs(structure) do		local thing = stucture[outter]		for j, inner in ipairs(thing) do			local thinger = structure[outter][inner]			for k, num in ipairs(thinger) do				page = page .. f:expandTemplate{title="Cg", args={"cell", structure[outer][inner][num], 32*(math.ceil(size/2)+option[j][k]), 21+(16*(k-1)), class="craftingGridNoBg"}}			end		end	end--

page = page .. f:expandTemplate{title="Cg", args={"cell", structure["A"]["A"][1], 32*(math.ceil(size/2)+0), 21+(16*0), class="craftingGridNoBg"}} --Hmmm, hardcoding? Nahhhhhhh, just testing. page = page .. f:expandTemplate{title="Cg", args={"cell", structure["A"]["B"][1], 32*(math.ceil(size/2)-1), 21+(16*1), class="craftingGridNoBg"}} page = page .. f:expandTemplate{title="Cg", args={"cell", structure["A"]["B"][2], 32*(math.ceil(size/2)+1), 21+(16*1), class="craftingGridNoBg"}} page = page .. f:expandTemplate{title="Cg", args={"cell", structure["A"]["C"][1], 32*(math.ceil(size/2)-2), 21+(16*2), class="craftingGridNoBg"}} page = page .. f:expandTemplate{title="Cg", args={"cell", structure["A"]["C"][2], 32*(math.ceil(size/2)+0), 21+(16*2), class="craftingGridNoBg"}} page = page .. f:expandTemplate{title="Cg", args={"cell", structure["A"]["C"][3], 32*(math.ceil(size/2)+2), 21+(16*2), class="craftingGridNoBg"}} page = page .. f:expandTemplate{title="Cg", args={"cell", structure["A"]["B"][2], 32*(math.ceil(size/2)+1), 21+(16*3), class="craftingGridNoBg"}} page = page .. f:expandTemplate{title="Cg", args={"cell", structure["A"]["B"][1], 32*(math.ceil(size/2)-1), 21+(16*3), class="craftingGridNoBg"}} page = page .. f:expandTemplate{title="Cg", args={"cell", structure["A"]["A"][1], 32*(math.ceil(size/2)+0), 21+(16*4), class="craftingGridNoBg"}}

page = page .. f:expandTemplate{title="Cg", args={"end"}} return page .. " " end

function tableSize(T) --Stupid Lua even needing this local count = 0 for _ in pairs(T) do 		count = count + 1 end return count end

return p