Module:Item: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary Tag: Manual revert |
mNo edit summary |
||
Line 18: | Line 18: | ||
function p.getItemNameAndIMG( frame ) | function p.getItemNameAndIMG( frame ) | ||
local arg = removeMinecraftPrefix(string.lower( | local arg = frame.args[1] | ||
local fileExists = fileModule.fileExists("File:".. | local text = removeMinecraftPrefix(string.lower(arg)) | ||
local fileExists = fileModule.fileExists("File:"..text..".png") | |||
if fileExists then | if fileExists then | ||
return "[[File:".. | return "[[File:"..text..".png|20px]] "..capitalizeFirstLetter(text) | ||
end | end | ||
return | return arg | ||
end | end | ||
return p | return p |
Revision as of 15:50, 21 October 2023
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
local function removeMinecraftPrefix(text)
if text:sub(1, 10) == "minecraft:" then
return text:sub(11)
else
return text
end
end
function p.getItemNameAndIMG( frame )
local arg = frame.args[1]
local text = removeMinecraftPrefix(string.lower(arg))
local fileExists = fileModule.fileExists("File:"..text..".png")
if fileExists then
return "[[File:"..text..".png|20px]] "..capitalizeFirstLetter(text)
end
return arg
end
return p