Is it possible to ignore case sensitivity when comparing a user's text input to a value?
For example, I'm using the code below to pick a random question to ask the player, taking the questions and answers from a pair of arrays:
Code:
def limitTest = 3
def questionsTest = ["What colour is an orange?",
"Who coded SexScripts?",
"What is the answer to life, the universe and everything?"]
def answersTest = ["orange",
"Doti",
"42"]
def questionSelect = getRandom(limitTest)
def questionAsked = questionsTest[questionSelect]
def answerCorrect = answersTest[questionSelect]
def question = getString("The question is:\n"+questionAsked+"\nAnswer?","")
if(question==answerCorrect) {
show("Correct!")
wait(3)
correct = true
} else {
show("I'm sorry! That's the wrong answer!\n\n The correct answer was '"+answerCorrect+"'.")
wait(5)
correct = false
}
questionArray.remove(questionAsked)
answerArray.remove(answerCorrect)
questionLimit --
Is there any way to easily make it so that, (for example) if the "What colour is an orange?" question is asked, the player can input either "orange" or "Orange" and be correct?
Or would this take a lot of extra coding to achieve?
My main problem is that I need to get the questions and answers from arrays, rather than using a simple "if(question=="orange" || question=="Orange")".
I've always assumed an "if x==y" had to be identical, and other cases needed to be specified ("if... else if" etc.) but is there a trick one can pull to make the comparison not care about case sensitivity?