Module:PlayerIMG

From EarthMC
Revision as of 17:31, 11 February 2024 by upgradewastaken#0 (talk | contribs) (Created page with "local p = {} --p stands for package local fileModule = require("Module:FileExists") --1: IGN 2: TYPE 3: VARIANT 4: SIZE function p.template( frame ) local ign = frame.args[1] local typeIMG = string.lower(frame.args[2]) local variant = string.lower(frame.args[3]) local size = "225px" if frame.args[4] ~= nil then size = frame.args[4] elseif typeIMG == "small" then size = "20px" end if typeIMG == "small" then typeIMG = "" end if string.sub(variant, 1, 1) =...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:PlayerIMG/doc

local p = {} --p stands for package

local fileModule = require("Module:FileExists")

--1: IGN 2: TYPE 3: VARIANT 4: SIZE
function p.template( frame )
	local ign = frame.args[1]
	local typeIMG = string.lower(frame.args[2])
	local variant = string.lower(frame.args[3])
	local size = "225px"
	if frame.args[4] ~= nil then
		size = frame.args[4]
	elseif typeIMG == "small" then
		size = "20px"
	end
	if typeIMG == "small" then
		typeIMG = ""
	end
	if string.sub(variant, 1, 1) == " " then
		variant = string.sub(variant, 2)
	end
	if typeIMG == "full" then
		if fileModule.fileExists("File:"..ign.." latest"..variant..".png") then
			typeIMG = "latest"
		end
	end
	if typeIMG ~= "" then
		typeIMG = " "..typeIMG
	end
    return "File:"..ign..typeIMG..variant..".png"
end

return p