From 1b4192257afc9c0cf20ca80ea6abe544834ff36e Mon Sep 17 00:00:00 2001 From: AreiaAard Date: Tue, 20 Apr 2021 14:09:18 -0400 Subject: [PATCH] Replace Utility.capitalize with Utility.pascalCase to capitalize every word in a string --- areia_consider.xml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/areia_consider.xml b/areia_consider.xml index b533dd5..bbea055 100644 --- a/areia_consider.xml +++ b/areia_consider.xml @@ -215,7 +215,7 @@ function Settings.ignore_flag_display() Utility.plugin_msg("Ignored flags:") for _, flag in ipairs{"aimed", "evil", "good", "sanctuary", "wounded"} do Utility.print(string.format(" @Y%-11.11s (%-5.5s@w)", - Utility.capitalize(flag), Settings.config.ignore.flags[flag] and "@GYes" or "@RNo" + Utility.pascalCase(flag), Settings.config.ignore.flags[flag] and "@GYes" or "@RNo" )) end end @@ -622,8 +622,12 @@ function Utility.display_help() Utility.print("TODO") end -function Utility.capitalize(str) - return string.format("%s%s", str:sub(1, 1):upper(), str:sub(2)) +function Utility.pascalCase(str) + return str:gsub("(%a)([%w_']*)", + function(first,remainder) + return string.format("%s%s", first:upper(), remainder:lower()) + end + ) end