ID:1632874
 
(See the best response by GhostAnime.)
Hey, I was wondering if there is a way to block out swearing on my game. I have it so if they swear the message does not send but then sometimes the word might be mistyped and it will send it out with the swear word. I have seen in some games before that when someone says the F word it says (the persons name) says: ****

is there a way to do that? I dont know how to so if someone can help me with it...Thanks

Oh cool, ill try it Thanks
But i want to add in stars, so if someone says: fuck you. it will say (usr) says: **** you. I dont want them to be totally stopped from swearing just i want it to be...censored i guess
You can include a library (or create) that contains a replace function.

One such is Forum account's Text.

The value you'd create the replacement from would be by using a function like the following:

proc/replicate(amount = 1, char = "*") //pass the length and the replacement value here.
. = ""
while(amount--)
. += char
OK cool, I will try it. but for the length and replacement, i would just add a list of words right? that should be censored or something else? Thanks
Best response
You will need to make your own function.

For example (ugh, I should have used that replicate function Pirion showed. Oh well):
var/list/Curses = list("ass" = "butt","damn")

mob/verb/Test()
src << Filter("Damn, that ass is fat... but how can you assess its firmness?") // Creepy? Maybe.

proc/Filter(msg as text)
for(var/curse in Curses) // Loop through the curse list

if(findtext(msg, curse)) // This is done in this example in case there's any words entered above that does not have another word replacing it
var/rep = Curses[curse] // Get the replacement word if defined in the list above (ex: Ass is replaced with butt)

if(!rep) // If there is no replacement defined
for(var/i = 1 to length(curse)) // Or use that replicate function Pirion showed *shrug*
rep += "*" // Replace with * (or you can do pick(with,different,symbols) like how Theodis had his

msg = replace(msg, curse, rep)

return msg


Note that words like "assessment" will become something unusual like "buttssessment" so you will have to think about what you add and how to overcome these issues

If you have an alternative for each word, we can cut things down:
var/list/Curses = list("ass" = "butt","damn" = "dang")
proc/Filter(msg as text)
for(var/curse in Curses)
msg = replace(msg, curse, Curses[curse])
return msg


For maybe replace it with different symbols... well, write one or just use Theodis' LanguageFilter for that *shrug*
//With LanguageFilter
var
{
CurseWords[] = list("damn","ass") // Initial value
}


mob/verb/Test(msg as text)
src << FilterString(msg)
Oh yes thank you, Using the guide you had shown me before, I think i can find a way to make an alternative, i will use whole cuss words and fragments, if it is a fragment say like fu, it would show up in a word like..wondferful but using the guide you showed me i can make it so if it is only whole cuss words it will censor.
It says Star Code.dm:16:error: replace: undefined proc
In response to Naruto 5292
That's from Forum account's Text which Pirion linked to earlier.
so i should put that replace code onto that?
Yes, I would advise that you either include/check-off that library to your project or make a note of where you got the function if you do copy it.

Just remember credit that library source appropriately; a little recognition uplifts the developers' heart.
Oh yes, I will be thanking the creator of that file within my game and tell him on byond pager.
but im not fully certain can u paste it like here i should put it or something also if you could show me what you meant by putting in Pirion's code for replace
I Wanna Do Something Similar To What Naruto Originally Wanted, But I Can't Figure Out How To Define Replace From This Conversation, Can Someone Explain In Detail? msg = replace(msg, profane, rep)
I have the code, i used this for a while but then i made a version from another piece of code I had. It's pretty useless because people always find a way to block the code like adding dots int between or space which would be very tedious for you to code in but i can send you the code later today if you want.
Language filters tend to be very iffy. If you replace on partial word matches, that works for the F word which doesn't show up in other words except forms of itself, but pretty much any other swear word is part of another innocuous word. And players soon get creative working around the filter. There is no ideal solution.
Ya, thats wht i was trying to explain
Bleh. The Current Filter I Have Removes The Whole Sentence Entirely.
The Only Reason Im Making It Like This Is Cuz It Also Interferes With Words That Aren't Even Swear Words But Words That Contain Them, lol.
Page: 1 2