Notoriouss
New Member
No matter what the version, distro or platform if it's Lua it will work
It's useful to format malformed strings, like: "hello My fRiend"
Remembering that this function will only upper words initials, if theres is a string: "I aM hungry", the function will turn into: "I Am Hungry"
How to install: If you are using TFS, you can just copy into lib/string.lua (or 011-string.lua for newer versions), if you are not then you'll have to copy into lib/functions.lua or the script.
How to use:
If theres someone who know how to simplify the function, please post it :]
It's useful to format malformed strings, like: "hello My fRiend"
Remembering that this function will only upper words initials, if theres is a string: "I aM hungry", the function will turn into: "I Am Hungry"
How to install: If you are using TFS, you can just copy into lib/string.lua (or 011-string.lua for newer versions), if you are not then you'll have to copy into lib/functions.lua or the script.
Lua:
string.iupper = function (s) -- by Notorious
local s = s:lower()
for init in s:gmatch("%s+(%a?)") do
s = s:gsub(" " .. init, (" " .. init):upper())
end
return s:sub(1, 1):upper() .. s:sub(2, #s)
end
Hope you enjoy ;dstr = "hello world from lua"
str:iupper() -- will return "Hello World From Lua"
If theres someone who know how to simplify the function, please post it :]
Last edited: