• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

function string.iupper(s)

Notoriouss

New Member
Joined
Nov 7, 2009
Messages
12
Reaction score
0
Location
Brazil
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.
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
How to use:
str = "hello world from lua"
str:iupper() -- will return "Hello World From Lua"
Hope you enjoy ;d
If theres someone who know how to simplify the function, please post it :]
 
Last edited:
Good notoriouss ;D
i will do now string.fix()
str = "hello world from lua"
str:fix() -- will return "Hello world from lua."
;D
 
Back
Top