Gordon_G Posted March 11, 2017 Share Posted March 11, 2017 Hello guys, I want to do a new outputChatBox for every points in my string : Exemple : text = "I like potatoes. I like salad too." -- output in game : I like potatoes. -- output in game : I like salad too. Is it possible ? Thanks ! Link to comment
Gordon_G Posted March 11, 2017 Author Share Posted March 11, 2017 (edited) local example = "an example string . an other ." sentences_ = {} sentence = "" for i in string.gmatch(example, "%S+") do -- This string.gmatch cut the string at every word sentence = sentence.." "..i if i == "." then -- Cut the string at the point and insert it into a table table.insert(sentences_,sentence) sentence = "" end end for k,v in ipairs(sentences_) do print(v) end I did it myself with the help of : http://lua-users.org/wiki/SplitJoin But it's not really optimized, any other way ? Edit : Sorry for the double post, I can't edit anymore the firt. Edited March 11, 2017 by Gordon_G Link to comment
Bonsai Posted March 11, 2017 Share Posted March 11, 2017 This is similar to what you tried but probably better than making the function yourself. https://wiki.multitheftauto.com/wiki/Split 1 Link to comment
Gordon_G Posted March 11, 2017 Author Share Posted March 11, 2017 Oh, I did not noticed it, sorry. Thanks for you help ! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now