Posted 31 December 2015 - 09:23 PM
Does anyone know how to make a if statement not caps sensitive? I am making a login program. Help appreciated! :)/>
You don't. if is just if and not IF. That is how Lua works.
input1 = read() -- i.e. "Hello"
input2 = read() -- i.e. "hELLo"
lowercase1 = string.lower(input1) -- will be "hello"
lowercase2 = string.lower(input2) -- will be "hello"
if(lowercase1 == lowercase2) then
-- there you go. this block will be executed, when your inputs match in non-case-sensitive manner
end
string.lower(text) will make text lower case.
You can convert a string to lower case ->input1 = read() -- i.e. "Hello" input2 = read() -- i.e. "hELLo" lowercase1 = string.lower(input1) -- will be "hello" lowercase2 = string.lower(input2) -- will be "hello" if(lowercase1 == lowercase2) then -- there you go. this block will be executed, when your inputs match in non-case-sensitive manner end
When dealing with passwords and things, you should consider not to do this, since you loose entropy and therefor security.
So there will be much more ways to get into a single account. i mean, in computercraft this has no effect, but sticking to good practices is always a nice thing to do.