Module:Weapon

local p = {}

-- remove whitespace from the front and back of a string local function trim(s) -- from PiL2 20.4 return (s:gsub("^%s*(.-)%s*$", "%1")) end

local function _split(inputstr, sep) if sep == nil then sep = "%s" end local t={} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do               table.insert(t, trim(str)) end return t end

-- split the defs into each type. general format is: -- Skill Chance=100,200,260 !!Burst Chance=140,220,280 !!KO Gauge=180,240,300

local function _PrintWeaponSkills(skillDefs) local o = "" local types=_split(skillDefs, "!!") for k,v in ipairs(types) do       local sType = _split(v,"=") local typeName = sType[1] local typeRankUnlocks = _split(sType[2],",") -- generate the skill header o = o .. "|-\n| '''Skill " .. k .. "''' \n\n" -- output the rank ubnlocks for each skill for lvl,rank in ipairs(typeRankUnlocks) do           o = o .. " Rank " .. rank .. "  \n" end end return o end

-- -- -- function p.PrintWeaponSkills(frame) if not frame or not frame.args then return '' end local args = frame.args -- force text to lowercase to ensure easier comparisons local skillDefs = trim(args[1])

return _PrintWeaponSkills(skillDefs) end

return p