Module:Dia code

--[[

This module is intended to provide an alt text (text that appears when the image doesn't load or is copied to a plaintext editor) for the image on, and to provide an appropriate link to the character when the image is clicked. It is a replacement for Template:Dia/code. ]] local p = {} -- This table provides the alt text and link destination for each code used in the Dia template. For codes not listed in the table, the alt text and link destination is equal to the code itself. Each line has the following form:   {"code", "alt text", "link destination"}, OR    {"code", "alt text and link destination"}, In the alt text, put the name of the character for the code or describe it. In the link destination, provide the name of the article/page which describes the character for the code. If the alt text and link destination is equal, use the latter form, which only has two entries. To not link to any article at all (for example, an article for the character doesn't exist, or the character is actually two characters whose relationship page doesn't exist), leave the link destination blank, like this:    {"code", "alt text", ""} local codes = { {"Hexagon", "Hexagon"}, } --[[ code This function returns the corresponding alt text or the link destination for the specified code. Usage:

Specify the code in the first parameter. If the second parameter is equal to "alt", the function will return the corresponding alt text for the code. Otherwise, the function will return the link destination for the code. If the code doesn't exist in the codes table (because the filename for the Dia template is exactly equal to the character's name), the code itself is returned, regardless of the second parameter. ]] function p.code( frame ) c = mw.text.trim(frame.args[1]); for i, a in ipairs(codes) do       if a[1] == c then if not ( frame.args[2] == "alt" or a[3] == nil ) then return a[3]; else return a[2]; end end end return c; end return p;