|
| 25 Jun 2015 07:55 PM |
The title may not be that clear but, I was wondering how you would check for certain words when someone talks.
I'm creating a custom chat GUI and I need to figure out how to do this so I can block at least some curse words.
I know of using msg == "Whatever" or msg:sub(1,5) == "Whatever" or even msg:sub(7) == "Whatever"
However, none of those will help me unless I know the specific location of the curse word, or if the curse word is the only thing they type.
Is there some way of finding a word in a message without knowing the location?
P.S.: Ive also heard of something like making the message go through Roblox's Filter System before posting it, but how would I do that? |
|
|
| Report Abuse |
|
|
Ictis
|
  |
| Joined: 01 Sep 2011 |
| Total Posts: 1216 |
|
|
| 25 Jun 2015 08:00 PM |
| http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation#string.match |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2015 08:09 PM |
or string.find http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation#string.match |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2015 08:10 PM |
it's too late
http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation#string.find ^ what i meant |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2015 08:37 PM |
I took a look at string.find and I managed to get it working, somewhat. I can't find multiple words, only 1.
string.find(box.Text:lower(), "curseWord")
That works, except of course curseWord would be replaced with an actual one. But, if I try doing something like this:
string.find(box.Text:lower(), "curseWord" or "anothercurseWord" or "anothercurseWord")
It wont work. So how can I search for multiple words. |
|
|
| Report Abuse |
|
|
Ictis
|
  |
| Joined: 01 Sep 2011 |
| Total Posts: 1216 |
|
|
| 25 Jun 2015 08:40 PM |
cursewords = {"curse","bad phrase","awful"}
for _, curse in ipairs(cursewords) do string.find(box.Text:lower(),curse) end |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2015 08:41 PM |
| box.Text:lower():find("CurseWord") or box.Text:lower():find("Abstract is dumb") then |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2015 08:45 PM |
Thanks guys, but yeah
Abstract is dum- *Banned*
:3 |
|
|
| Report Abuse |
|
|
|
| 25 Jun 2015 08:47 PM |
| i know i've seen that wiki page with roblox's real filter which returns true or false try finding it in the wiki |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 25 Jun 2015 09:38 PM |
you're better off doing this:
http://wiki.roblox.com/index.php?title=FilterStringForPlayerAsync |
|
|
| Report Abuse |
|
|