• 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!

TFS 0.X to return initial capitula

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
201
I use tibia 8.6 tfs 0.4

Hello, how are you?
How is the function to return the word with the initial capital letters?

For exemple
local name = orshabaal the boss

print(""..name.."")

How can i print Orshabal The Boss? with capital letters?
 
Solution
Lua:
function capitalize(str)
    return str:gsub("%a+", function(c) return c:sub(1, 1):upper() .. c:sub(2) end)
end

Lua:
print(capitalize('orshabaal the boss')) -- prints Orshabaal The Boss

also you don't need to use "".. name .."" to print name
you can simply do print(name), no need to concat a variable to an empty string to print it
Lua:
function capitalize(str)
    return str:gsub("%a+", function(c) return c:sub(1, 1):upper() .. c:sub(2) end)
end

Lua:
print(capitalize('orshabaal the boss')) -- prints Orshabaal The Boss

also you don't need to use "".. name .."" to print name
you can simply do print(name), no need to concat a variable to an empty string to print it
 
Solution
Back
Top