Module:Item

From EarthMC
Revision as of 14:43, 21 October 2023 by upgradewastaken (talk | contribs)
Jump to navigation Jump to search

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

local p = {}

local fileModule = require("Module:FileExists")

local function capitalizeFirstLetter(input)
	local firstLetter = input:sub(1, 1)
	local restOfString = input:sub(2)
	return firstLetter:upper() .. restOfString:lower()
end

function p.getItemNameAndIMG( frame )
    local arg = string.lower(frame.args[1])
	local fileExists = fileModule.fileExists("File:"..arg..".png")
	if fileExists then
		return "[[File:"..arg..".png|20px]] "..capitalizeFirstLetter(arg)
	end
	return capitalizeFirstLetter(arg)
end

return p