I Need Help On My Eye Test Game
-
Hi TurtleGamer! Very nice game idea! I think both problems can be solved by editing line 90, currently
if answer == input("What does it say?") then
to
if answer == answer[num] then
so that it's checking against the random selection you made before. With input() there, you're getting a second, new input from the player, which will always be 'true' so it counts it as correct. Hope that makes sense. You'll also need to change line 110, either to check against "Cloud" as you have printed a few lines above, or changing
num
to a new random number before printing, then repeating the code from the first question. -
@kat So basically you want me to change line 90, and after the first question, change num to a new number and make a new word list for question 2? (If that makes sense)
-
@TurtleGamer-0 You won't need a new word list, just the line
num = random(50)
after the first question, yes :) You'll need to change lines 108 and 110 as well so that it prints and checks the newanswer[num]
. -
@kat I thiiiiink I did everything you said but if I get it right or wrong it always shows an error message :(
-
@turtlegamer-0 What does the message say?
-
@kat there was an error on line 90 and the error code says: "String index out of bounds. (String index length: 6, index: 17)" I have no idea what it's trying to say 😓
-
@turtlegamer-0 Ah ok, there's something I didn't spot. Both your array of answers and the variable that stores the player's response are both named "answer" and that's giving you the problem. Try changing lines 89 and 90 to say something like
playerAnswer = input( "What does it say?" ) if playerAnswer == answer[num] then
-
@kat Thank you so much! Now my eye test is ready to play! 😁 Here's the NEW ID!
ID: VQ173MND1Q -
@turtlegamer-0 You're welcome :) Well done, it's a very nice program! Excited to see what you do next!
-
@kat Wait, I actually think it's not finished. 😢 I've noticed that if you get it right, everything is perfect, but if you get it wrong, it makes you still type it twice. So I did an experiment where I added another question, and if you get it wrong it makes you type it 3 times, so it makes you type it again the same amount of questions that there are... If that makes sense
-
@turtlegamer-0 Ah, I think I see the problem. The first question doesn't have an
else
, so if you get it wrong there's noclear()
orupdate()
and you keep seeing the same word. To fix it you can copy the wholeelse
section from line 130 to 148 and paste it before theendif
on line 105 and it should work properly :)