Module:XC3 enum enhance

local enhance_table = mw.loadData("Module:XC3 enum enhance/data") local enhance_table_2 = mw.loadData("Module:XC3 enum enhance/data 2") local enhance_ms_table = mw.loadData("Module:XC3 enum enhance/captions") local enhance_ms_table_names = mw.loadData("Module:XC3 enum enhance/names")

local xc3_enum_enhance = {}

function xc3_enum_enhance.formatEnhance(e) extraParams = enhance_table_2[e[2]] if e[2] == 0 then extraParams = {"00000000",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} end caption = enhance_ms_table[e[5]] -- this gsub format lets us do a single operation rather than "three but we usually only need one" caption = caption:gsub("%[ML:EnhanceParam paramtype=%d ]",{["[ML:EnhanceParam paramtype=1 ]"]=e[3],["[ML:EnhanceParam paramtype=2 ]"]=e[4],["[ML:EnhanceParam paramtype=3 ]"]=extraParams[2]}) return caption end

function xc3_enum_enhance.getEnhanceName(frame) id = tonumber(frame.args[1]) if id == 0 then return "none" end enhanceEntry = enhance_table[id] if enhanceEntry then extraParams = enhance_table_2[enhanceEntry[2]] return frame:preprocess(enhance_ms_table_names[extraParams[16]]) else return "undefinedEnhance["..id.."]" end end

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

return xc3_enum_enhance