Module:Sandbox

local p = {} p.cell = function( f ) local args = f.args or f       if f == mw.getCurrentFrame and args[1] == nil then args = f:getParent.args else f = mw.getCurrentFrame end args = require( Module:ProcessArgs ).norm( args ) local item = args[1] local body = mw.html.create( 'span' ):addClass( 'grid' ):css{ ['vertical-align'] = args.align } if args['no-bg'] then body:addClass( 'grid-plain' ) end if args.class then body:addClass( args.class ) end if args.style then body:cssText( args.style ) end if not item then body:tag( 'br' ) return tostring( body ) end local mods = require( Module:Mods ) local mod = mods.getData(string.upper(args.mod or '')) or { abbr="", mod="", name="", localised="" } local link = args.link or '' if link:lower == 'none' or link:lower == 'false' then link = nil else if link == '' then link = item if mod.link and ( args.dis or  ) ==  then link = link .. ' (' .. mod.link .. ')' end end body:wikitext( , link, require( [[Module:Language ).link, '|' )       end        local icon = body:tag( 'span' )        local title = args.title or args.tooltiptext        if not title then                title = item        elseif title:lower == 'none' then                title =         elseif title:match( '&' ) then                body:attr( 'data-minetip-title', title )                title = title:gsub( '&[0-9a-fk-or]',  )                if title ==  then                        title = item                end        end        ( link and icon or body ):attr{ title = title }        body:attr{ ['data-minetip-text'] = args.desc }        icon:wikitext( f:callParserFunction( '#icon', { item = item, mod = mod.abbr } ) )        local num = tonumber( args[2] or 1 )        if num and num < 1000 and (num > 1 or (args.forceshownum == 'true' and num > 0)) then                local number = icon:tag( 'span' ):addClass( 'grid-number' ):wikitext( num )                if args.numstyle then                        number:cssText( args.numstyle )                end        end        if link then                body:wikitext( ']]' ) end return tostring( body ) end

p.benchmark = function(f) local title = mw.title.new("User:Retep998/Sandbox/GT2") local content = title:getContent local contentLines = {} for line in content:gmatch("[^\r\n]+") do       contentLines[#contentLines+1] = line end

local result = 0 if f.args[1] == "lines" then for i=1,5 do           local next = 1 local out = {} for _,line in ipairs(contentLines) do               out[next] = f:preprocess(line) out[next+1] = "\n" next = next + 2 end result = table.concat(out) end else for i=1,5 do           result = f:preprocess(content) end end

return result end

p.cell_ore = function( f ) local args = f.args or f       if f == mw.getCurrentFrame and args[1] == nil then args = f:getParent.args else f = mw.getCurrentFrame end args = require( Module:ProcessArgs ).norm( args ) local item = args[1] local body = mw.html.create( 'span' ):addClass( 'grid' ):css{ ['vertical-align'] = args.align } if args['no-bg'] then body:addClass( 'grid-plain' ) end if args.class then body:addClass( args.class ) end if args.style then body:cssText( args.style ) end if not item then body:tag( 'br' ) return tostring( body ) end local mod = require(Module:Mods).getData(string.upper(args.mod or '')) or { abbr="", mod="", name="", localised="" } local link = args.link or '' if link:lower == 'none' then link = nil else if link == '' then link = item if mod.link and ( args.dis or  ) ==  then link = link .. ' (' .. mod.link .. ')' end end body:wikitext( , link, require( [[Module:Language ).link, '|' )       end        local icon = body:tag( 'span' )        local lang = require(Module:Utility_functions).pageSuffix:sub(2)        local title = args.title or args.tooltiptext or f:callParserFunction("#iconloc", {item, mod.abbr, "name", lang})        if not title or title ==  then        	title = item        elseif title:lower == 'none' then                title =         elseif title:match( '&' ) then                body:attr( 'data-minetip-title', title )                title = title:gsub( '&[0-9a-fk-or]',  )                if title ==  then                        title = item                end        end        ( link and icon or body ):attr{ title = title }        if (not args.desc or args.desc == ) and args.oretag then        	args.desc = '&7' .. mod.localised .. '/&9' .. args['oretag']    	end        body:attr{ ['data-minetip-text'] = args.desc or f:callParserFunction("#iconloc", {item, mod.abbr, "description", lang})}        icon:wikitext( f:callParserFunction( '#icon', { "", item = item, mod = mod.abbr } ) )        local num = tonumber( args[2] or 1 )        if num and num > 1 and num < 1000 then                local number = icon:tag( 'span' ):addClass( 'grid-number' ):wikitext( num )                if args.numstyle then                        number:cssText( args.numstyle )                end        end        if link then                body:wikitext( ']]' ) end return tostring( body ) end

return p