Module:Illustration: Difference between revisions
From Terra Invicta Official Wiki
Llamageddon (talk | contribs) mNo edit summary |
Llamageddon (talk | contribs) mNo edit summary |
||
| Line 70: | Line 70: | ||
end | end | ||
end | end | ||
returnString = returnString .. tconcat( Illustrations, '|x128px]] | returnString = returnString .. tconcat( Illustrations, '|x128px]] | [[File:') | ||
returnString = returnString .. '|x128px]]' | returnString = returnString .. '|x128px]]' | ||
end | end | ||
Revision as of 18:34, 9 December 2025
Documentation for this module may be created at Module:Illustration/doc
-- This is meant to be a way to reference and use the illustrations in the game easily on the wiki and inside other templates.
-- No idea what I'm doing really, and need a break, so just leaving whatever this is here for now.
local p = {}
-- Almost 1500 lines, probably want to split into categories for more specific functions to use efficiently?
local illusData = mw.loadData('Module:Illustration/data')
-- Syntax borrowed from modules this one is emulating.
-- Commenting out for use later ##local ssub = string.sub
local tinsert = table.insert
local tconcat = table.concat
local slower = string.lower
-- Currently just trying to get this to output all entries for a key into a readable string, to test the basics work.
function p.Illusnametest (frame)
local illusdataName = frame.args[1]
-- Check input makes sense
if not illusdataName then
return 'No illustration data name specified.'
end
if not illusData[illusdataName] then
illusdataName = slower(illusdataName)
end
if not illusData[illusdataName] then
illusdataName = mw.text.trim(illusdataName)
end
if not illusData[illusdataName] then
return 'Data name not recognized.'
end
local returnString = 'Illustrations: '
if illusData[illusdataName] then
local Illustrations = {}
for j, file in ipairs(illusData[illusdataName]) do
if file ~= '' then
tinsert(Illustrations, file)
end
end
returnString = returnString .. tconcat( Illustrations, ' , ')
returnString = returnString .. '\nDid this work?'
end
return returnString
end
-- This should output any recognized illustrations as a sequence of (or just one) thumbnail(s) in wikitext
function p.Illus (frame)
-- This just checks matching dataName. More useful within other modules/templates.
-- Next function planned will convert displayName to dataName first. More useful for humans.
local illusdataName = frame.args[1]
-- Check input makes sense
if not illusdataName then
return 'No illustration data name specified.'
end
if not illusData[illusdataName] then
illusdataName = slower(illusdataName)
end
if not illusData[illusdataName] then
illusdataName = mw.text.trim(illusdataName)
end
if not illusData[illusdataName] then
return 'Data name not recognized.'
end
local returnString = '[[File:'
if illusData[illusdataName] then
local Illustrations = {}
for j, file in ipairs(illusData[illusdataName]) do
if file ~= '' then
tinsert(Illustrations, file)
end
end
returnString = returnString .. tconcat( Illustrations, '|x128px]] | [[File:')
returnString = returnString .. '|x128px]]'
end
return returnString
end
return p


