AntiCursing

Get help using Construct 2

Post » Thu Jun 21, 2012 9:43 pm

How would I go about creating an anti-cursing protocol for a text box that the player enters his or hers name in? I have it so another text box shows what the user typed into the input text box.

Thanks
B
12
S
2
Posts: 41
Reputation: 1,553

Post » Thu Jun 21, 2012 9:53 pm

One way would be to create a dictionary containing the forbidden words and then when the text is changed or submitted you'd have to parse the text looking for those words. Maybe using the find() string expression would work instead of full blown parsing. Not too bad if your list of forbidden words isn't too long...


kittiewan2012-06-21 21:54:24
B
29
S
11
G
12
Posts: 281
Reputation: 11,878

Post » Fri Jun 22, 2012 1:22 am

Hi kittiewan, could you possibly post an example on how to do this. I haven't use the dictionary object before. Thanks
B
12
S
2
Posts: 41
Reputation: 1,553

Post » Sat Jun 23, 2012 8:43 pm

I'll try to post a simple example later today. The dictionary is an awesome plugin, very easy to use.
B
29
S
11
G
12
Posts: 281
Reputation: 11,878

Post » Sat Jun 23, 2012 8:57 pm

Awesome thanks!
B
12
S
2
Posts: 41
Reputation: 1,553

Post » Sat Jun 23, 2012 9:15 pm

Okay, I got it done. Now--don't laugh--my list of curses is very G-rated. I wouldn't really check for those!

This is very simple implementation just to give you a direction to go in. When user clicks the OK button it checks the length of the username (just for kicks) and it looks for any instance of a bad word in a string, even if its appearance in a longer word is perfectly innocent. For example, it will flag "damnable" because it contains "damn". Also, if there are two "curse" words, like "goshdarnit" the error message comes up twice. You could set a flag if you only want it to come up once, or better yet use a counter to say how many disallowed words appear.

CurseCatcher.capx

EDIT: I just couldn't leave it the way it was. I added a couple of events to keep track of the number of "curse" words found. kittiewan2012-06-24 00:44:49
B
29
S
11
G
12
Posts: 281
Reputation: 11,878

Post » Sun Jun 24, 2012 6:26 pm

Wow excellent example! Thanks so much!
B
12
S
2
Posts: 41
Reputation: 1,553


Return to How do I....?

Who is online

Users browsing this forum: DiabloOvermind, emoticon, odiusfly and 17 guests