AntiCursing

0 favourites
  • 7 posts
  • 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 <img src="smileys/smiley2.gif" border="0" align="middle" />

  • 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...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi kittiewan, could you possibly post an example on how to do this. I haven't use the dictionary object before. Thanks

  • I'll try to post a simple example later today. The dictionary is an awesome plugin, very easy to use.

  • Awesome thanks! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • 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.

  • Wow excellent example! Thanks so much!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)