Модуль:БлокСетка

Этот модуль реализует {{БлокСетка}}.

local p = {} function p.grid( f ) local args = f.args or f if f == mw.getCurrentFrame() and f.args[1] == nil then args = f:getParent().args end local rows = {} local scale = tonumber(args["масштаб"]) or 1 if scale == 0 then scale = 1 end local size = 16 * scale local sprite = require('Модуль:Спрайт').sprite local cats = {} local keys = args.keys or args for k, v in ipairs( args ) do local row = {} for v2 in mw.text.gsplit( v:gsub( '^%s-\n+', '' ):gsub( '\n+%s-$', '' ), '' ) do if mw.text.trim( v2 ) == '' or keys[v2] == 'воздух' then table.insert( row, ' style="width:' .. size .. 'px;height:' .. size .. 'px" | ' ) else local icon, category = sprite{keys[v2], ["данные"]="Спрайт/Блок", ["масштаб"]=scale} table.insert(row, icon) table.insert(cats, category) end end table.insert( rows, table.concat( row, ' || ' ) ) end local spacing = tonumber(args["промежутки"] or '') or 0 return '{| cellspacing="' .. spacing .. '" cellpadding="0" style="line-height:0"\n|' .. table.concat( rows, '\n|-\n| ' ) .. '\n|}' .. table.concat(cats) end return p 
В данной статье используются материалы из статьи «Модуль:БлокСетка» с вики-сайта Minecraft Wiki, расположенного на Фэндоме, и они распространяются согласно лицензии Creative Commons Attribution-NonCommercial-ShareAlike 3.0. Авторы статьи.