Module:SkillParse

From Caves of Qud Wiki
Revision as of 15:40, 31 July 2019 by Egocarib (talk | contribs) (module to parse Skill strings (i.e. convert "LongBlades" to "Long Blades"))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Template-info.png Documentation

Module to parse Skill strings from ObjectBlueprints. For example, converts "LongBlades" to "Long Blades" and "HeavyWeapons" to "Heavy Weapons".

Usage

{{#invoke: SkillParse | parse | (SkillName here) }}

Code:

{{#invoke: SkillParse | parse | LongBlades }}

Result:

Long Blades


local p = {}

function p.parse(frame)
  local skillString = frame.args[1]
  local prettyString = ""
  for w in string.gfind(skillString, "%u%l+") do
    if (string.len(prettyString) > 0) then
      prettyString = prettyString .. " "
    end
    prettyString = prettyString .. w
  end
  return prettyString
end

return p