Module:XCX enum enhance

local enhance_table = mw.loadData("Module:XCX enum enhance/data") local enhance_ms_table = mw.loadData("Module:XCX enum enhance/captions")

local xcx_enum_enhance = {}

function xcx_enum_enhance.formatEnhance(e) caption = enhance_ms_table[e[10]] -- this gsub format lets us do a single operation rather than "three but we usually only need one" caption = caption:gsub("<>",{["< >"]=e[3],["< >"]=e[6],["< >"]=e[7]}) return caption end

function xcx_enum_enhance.getEnhanceCaption(frame) id = tonumber(frame.args[1]) enhanceEntry = enhance_table[id] if enhanceEntry then return frame:preprocess(xcx_enum_enhance.formatEnhance(enhanceEntry)) else return "undefinedEnhance["..id.."]" end end

function xcx_enum_enhance.getEnhanceData(frame) id = tonumber(frame.args[1]) enhanceEntry = enhance_table[id] if enhanceEntry then -- this is probably better actually than trying to make a loop out of it		return enhanceEntry[1]..","..enhanceEntry[2]..","..enhanceEntry[3]..","..enhanceEntry[4]..","..enhanceEntry[5]..","..enhanceEntry[6]..","..enhanceEntry[7]..","..enhanceEntry[8]..","..enhanceEntry[9]..","..enhanceEntry[10] else return "undefinedEnhance["..id.."]" end end

return xcx_enum_enhance