ID:270081
 
What I mean is, say I put some words into a list, like the S and F word. Is it possible to its to check for any sort of spelling of it without making a huge list? You know, like say they type S*H*I*(blank) instead of saying it, and it would still censor it, or in my case, mute them.
This would have to be a very complicated system to catch words like that because many words use the same letters as any one cuss word and you would be censoring.
Sadly this isn't possible. The S and F words in particular can be combined with other words in many many many many ways.

Lummox JR
In response to Lummox JR
Oh well, I guess I'll have to be sure to catch any of those words and mute them for saying it. Oh well, thanks anyway guys.
Try using ckey. Say you were censoring the word 'fred'

If you had a list containing all the different words a person had said using whatever say verb, then you'd loop through them all and check if ckey(t)=="fred".

That would catch "f red", "f*r*e*d", "FRED!", and other assorted combinations of spaces, punctuation marks, and interesting capitalisation.

It wouldn't catch it if the letters are out of order or new ones are thrown in, though. So it wouldn't get 'dref' or 'faraead'.

And you can always run words together 'TodayfredandIwentswimming'
In response to Jp
What Lummox is hinting at, is that its simply not applicable to do so as many word combinations are possible including the aforementioned words. You will catch cases which aren't supposed to be, and people will still find ways to abuse the filter. And the more you compensate by laxing the filter, the more you affect completely innocent people by censoring completely idiotic combinations of words to compensate for trolls.

In other words: Find other solutions.
In response to Alathon
No reason to not have a basic, simple, easy filter set up for the easy stuff. 'You can't catch them all' isn't an excuse to not catch some of them when it's easy and shouldn't affect innocent players at all. Try taking a word someone might want to filter and making a phrase someone innocent might want to say, with the letters in the right order, and only punctuation or spaces between letters.
In response to Alathon
Yeah, unfortunately automatic moderation just won't cut it. What most games do is make a simple easily-bypassed filter and then make bypassing it a bannable offence. Anything more complicated will take too long and get you into strife.
In response to Crispy
I think I might use Jp's idea. Think you could explain to me how one could go about it? That or show me in an example, although, I think I get it, I just want to be sure. Thanks guys.
In response to Pyro_dragons
The first bit is to split the phrase up into words.

Now, let's say your 'say' verb gets a phrase, t. You can find words just by finding everything between spaces. Note that this particular version won't get 'f red' because it sees that as two different words. You could look at adjacent words added together, if you wished.

So, you're going to need findtext() and copytext().

var/t2=t //A temporary string we can do interesting things to
var/list/words=list() //The list of words we find
while(t2) //While t2 is not "", 0 or null (It should go to "")
words+=copytext(t2,1,findtext(t2," ")) //Copy the bit of t2 between the start of the string and the first " " found in it. Add that to the words list.
t2=copytext(t2,findtext(t2," ")+1) //Make t2 equal to the bit 'after' the first space found in it.


That gets you a list of words.

Now, you'll also need a global, mod-editable list of 'banned words', that you can't say. Let's call this list 'badwords'.

You want to check if the ckey of any of the words in the 'words list' matches any of the words in the banned lists. Which is simple:

 for(var/k in words) if(ckey(k) in badwords) world << "Gasp! A bad word!" //Or whatever else you want to do


Note - This is untested. The copytext stuff may need some jiggling.
In response to Jp
can someone tell me how to censor words?
In response to Jp
And you could make it so you could access the list and add to to it ingame, so you would catch more and more variations
In response to Alathon
Alathon wrote:
What Lummox is hinting at, is that its simply not applicable to do so as many word combinations are possible including the aforementioned words. You will catch cases which aren't supposed to be, and people will still find ways to abuse the filter. And the more you compensate by laxing the filter, the more you affect completely innocent people by censoring completely idiotic combinations of words to compensate for trolls.

In other words: Find other solutions.

My own approach is sort of a hybrid. Obviously some words can be found in other forms, like the S word appears in innocent words. However the good old F bomb appears in no legitimate words, and can be censored easily. For most cuss words, then, you'd want any filter to look for a whole word and you could simply include some obvious derivatives as well. For others, like F, finding any instance would be a breach.

Lummox JR
In response to Tails5
Well, you could take that snippet I posted, and then do something like this:

var/r=""
for(var/k in words)
if(!(ckey(k) in badwords)) r+=k+" " //The word passes through the filter. Remember operator precedence!
else r+="\[CENSORED\] "
r=copytext(r,1,length(r)-1) //Remove the trailing space


Then output r.