Sign in to follow this  
Lynch

[HELP] Case sensitive table

Recommended Posts

So, if I derive values from a certain table and use those values to do something, they will always be case sensitive. How can I remove that? I don't want the values of the table to be case sensitive,

For example,

local values = {"Hi", "Hello", "Hey"}

And if I detect if a player said one of these in chat by looping through them, it will work but only if the player typed the first letter capital.

addEventHandler("onPlayerChat", root, function(message, messageType)
    if not messageType == 0 then
        return
    end
    for _, msg in pairs(values) do
        if message == msg then
            outputChatBox("Console: Hey!", source, 255, 100, 100)
        else
            return
        end
    end
end)

I heard string.gsub can do this but I'm not sure how to use that. Any help regarding this would be appreciated.

Share this post


Link to post

I don't know how you can use string.gsub but you could just do your table all in lower case

From

local values = {"Hi", "Hello", "Hey"}

To

local values = {"hi", "hello", "hey"}

And useĀ 

string.lower( string )

In order to set the player's input in lower case

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.