No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
local args = getArgs(frame); | local args = getArgs(frame); | ||
local phrase = args[1] | local phrase = args[1] | ||
if (string.starts(phrase, "{{{")) then | |||
return "" | |||
end | |||
local result = "" | local result = "" | ||
for i = 1, #phrase do | for i = 1, #phrase do | ||
local c = phrase:sub(i,i) | local c = phrase:sub(i,i) | ||
local queryFields = 'cipherCharacter=cipherCharacter,imageName=imageName' | if c == " " then | ||
result = result .. c | |||
else | |||
local queryFields = 'cipherCharacter=cipherCharacter,imageName=imageName' | |||
local args = { | |||
where = string.format('ZonaiRunes.cipherCharacter="%s"', c), | |||
format = 'table', | |||
limit = 1 | |||
} | |||
local items = cargo.query("ZonaiRunes", queryFields, args) | |||
for r = 1, #items do | |||
local item = items[r] | |||
result = result .. string.format("[[File:%s]]", item.imageName) | |||
end | |||
end | end | ||
end | end |
Revision as of 11:32, 28 December 2023
Documentation for this module may be created at Module:TextToZonaiRunes/doc
local p = {} local cargo = mw.ext.cargo function p.textToZonaiRunes(frame) local getArgs = require('Module:Arguments').getArgs local args = getArgs(frame); local phrase = args[1] if (string.starts(phrase, "{{{")) then return "" end local result = "" for i = 1, #phrase do local c = phrase:sub(i,i) if c == " " then result = result .. c else local queryFields = 'cipherCharacter=cipherCharacter,imageName=imageName' local args = { where = string.format('ZonaiRunes.cipherCharacter="%s"', c), format = 'table', limit = 1 } local items = cargo.query("ZonaiRunes", queryFields, args) for r = 1, #items do local item = items[r] result = result .. string.format("[[File:%s]]", item.imageName) end end end return result end return p