Moderators IIYAMA Posted November 16, 2014 Moderators Posted November 16, 2014 local reactionCharacters = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"} local reactionSpecialCharacters = { "!","@","~","&","#","$","%","*","?","+","-","_" --[[,"^",,"`" ,"(",")",,,"=","{","}","[","]",";",":","'",'"',"|","<",",",">",".","/",]] } local function playerChat(message, messageType) if messageType == 0 then --Global (main) chat if newReaction then if string.match(message,newReaction) then outputChatBox("Good result.") cancelEvent() end end end end addEventHandler("onPlayerChat", root, playerChat) I am trying to make a reaction system. But with some characters math.match don't work. Does anybody knows which ones don't work? Thank you very much.
MTA Team botder Posted November 16, 2014 MTA Team Posted November 16, 2014 That happens because e.g. "%" is a part of a pattern http://lua-users.org/wiki/PatternsTutorial
Moderators IIYAMA Posted November 16, 2014 Author Moderators Posted November 16, 2014 It is only that character which causes this problem?
MTA Team botder Posted November 16, 2014 MTA Team Posted November 16, 2014 http://wiki.roblox.com/index.php?title=String_pattern Check that page out
Moderators IIYAMA Posted November 16, 2014 Author Moderators Posted November 16, 2014 That are a lot of characters. Is there a way to disable the function of the special characters while comparing?
MTA Team botder Posted November 16, 2014 MTA Team Posted November 16, 2014 You can escape the special characters with a "%" prefix (e.g. "%%s", "%%", "%.")
Moderators IIYAMA Posted November 17, 2014 Author Moderators Posted November 17, 2014 I understand now what you mean. Except how do I know which characters do I have to ignore? string.gsub is also using these special characters, so I can't replace them using that.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now