|
| 06 Nov 2014 01:43 PM |
How do I find certain text before a character in a message? I'm still a beginner in lua so I'm not very familiar with string.
|
|
|
| Report Abuse |
|
|
|
| 06 Nov 2014 01:44 PM |
**I'm still mediocre in Lua. I never looked at string :) |
|
|
| Report Abuse |
|
|
|
| 06 Nov 2014 01:52 PM |
| Strings are just words, letters, and anything else in between quotation marks. |
|
|
| Report Abuse |
|
|
|
| 06 Nov 2014 01:54 PM |
if msg:sub(1,4) == "123/" then print(msg:sub(5)) end
example:
123/hi
output: >hi |
|
|
| Report Abuse |
|
|
|
| 06 Nov 2014 02:05 PM |
@Jarod I know what string is. I never asked what it is
nop. Let me ask this more clearly. How do I find unknown text before a certain character?
say for example if i say hi/ it would print hi if i said hellos/ it would print hellos/ so basically it finds what's before / no matter how many characters there are
|
|
|
| Report Abuse |
|
|
|
| 06 Nov 2014 02:09 PM |
m= 0 if msg:match('/') then repeat m = m+1 txt = msg:sub(m,m) until txt == '/' print(msg:sub(1,m)) end |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 06 Nov 2014 02:27 PM |
function split(input) local output = {} input:gsub("[^/]+", function(word) table.insert(output, word) end) return output end
local text = "Hello/How/Are/You/Doing/Today?"
for _, word in pairs(split(text)) do print(word) end --[[>Hello How Are You Doing Today?]] |
|
|
| Report Abuse |
|
|
|
| 06 Nov 2014 03:00 PM |
Can someone help me with another thing? thread - http://www.roblox.com/Forum/ShowPost.aspx?PostID=149286010 |
|
|
| Report Abuse |
|
|