Module:SS Coin
Jump to navigation
Jump to search
Documentation for this module may be created at Module:SS Coin/doc
local p = {}
function p.getCharacterIDs(frame)
local characterName = frame.args[1] -- The character name to search for
local data = mw.loadJsonData('JoJo Wiki:SS Medals')
local matches = {}
-- Iterate through each entry in the data
for id, entry in pairs(data) do
local characters = entry.character
if type(characters) == "table" then
-- If characters is a table, check each element
for _, name in ipairs(characters) do
if name == characterName then
table.insert(matches, id)
break -- Stop checking this entry if a match is found
end
end
elseif type(characters) == "string" and characters == characterName then
-- If characters is a string and matches the characterName
table.insert(matches, id)
end
end
-- Format the matches into template calls
local output = {}
for _, id in ipairs(matches) do
table.insert(output, frame:preprocess('{{CoinS2|' .. id .. '}}'))
end
return table.concat(output, "\n")
end
return p