try this :
Code:
local name = "Lightning Charged Iron Dwarf"
local output = ""
local count = 0
local nameCount = 0;string.gsub(name,"(%w+)", function(w) nameCount = nameCount+1 end)
for token in name:gmatch("%a+") do
count=count+1;
output = output .. ((count<nameCount) and string.sub(token,1,1)..". " or token)
end
print(output)
I'm sure there is a better/shorter way of returning an integer that represents the amount of words in a string.
possibly even a better way to do this overall, but this outputs :