+mayela mingi Posted May 17, 2008 Share Posted May 17, 2008 I set up a multipe choice question. A. choice 1 B. choice 2 (the correct answer) C. choice 3 D. choice 4 After the user has mad a choice, how do I check if the entered choice is correct or not? I can use the if..then..else structure, but I can't find what values to compare. I've made 2 variables correctAnswer, and playeranswer. I assign correctanswer 2, for the 2nd line (or , ...when I create a variable, it only allows me to make numerical values for variables, the text and logic are greyed out. So I'm hoping that when the user clicks on the list, they will have a value of the line number. Anyways, I can't find 1. where the value is stored for what the player clicks on, on a multiple choice list question. 2. If that is compareable to a another variable, like correctanswer, I want to complete a task based on whether the answer was answered correctly. Pretty basic question, should have an easy answer. Any help is appreciated. Quote Link to comment
Ranger Fox Posted May 17, 2008 Share Posted May 17, 2008 You do the comparison in the input control's "When a player inputs data" section. For the input control itself, you store the player's input in a variable you create. You can create another with the correct answer. However, the correct answer must match the text of whatever the user selects on the screen. Therefore, in your example, the correct answer value will be "choice 2". Here's how I did this: -- I created a new zone and went to the "When a player enters a zone" section. -- I selected the option to get input from a player. -- I didn't have an input set up, so I created a new one right there. -- I did the MultipleChoice type and added the choices. I also created a variable called "var" to store the input's result. -- I saved the script and went back to the main window and created a "CorrectAnswer" variable and set its value to "choice 2". -- I went to "Tasks" and created a task. -- I went to the "Input" section and added a script for when a player inputs data. -- From here, I added the if/then. If "var" equals "CorrectAnswer", I marked the task as complete. If you need further explanation, I can provide that later Saturday night. I'm also uploading a zipped copy of what the code should look like for your example. If the hands-on approach helps you more, I suggest looking at it. mingi.zip Quote Link to comment
+mayela mingi Posted May 18, 2008 Author Share Posted May 18, 2008 (edited) You do the comparison in the input control's "When a player inputs data" section. For the input control itself, you store the player's input in a variable you create. You can create another with the correct answer. However, the correct answer must match the text of whatever the user selects on the screen. Therefore, in your example, the correct answer value will be "choice 2". Here's how I did this: -- I created a new zone and went to the "When a player enters a zone" section. -- I selected the option to get input from a player. -- I didn't have an input set up, so I created a new one right there. -- I did the MultipleChoice type and added the choices. I also created a variable called "var" to store the input's result. -- I saved the script and went back to the main window and created a "CorrectAnswer" variable and set its value to "choice 2". -- I went to "Tasks" and created a task. -- I went to the "Input" section and added a script for when a player inputs data. -- From here, I added the if/then. If "var" equals "CorrectAnswer", I marked the task as complete. If you need further explanation, I can provide that later Saturday night. I'm also uploading a zipped copy of what the code should look like for your example. If the hands-on approach helps you more, I suggest looking at it. Thank you! Thats very helpful. Now, how do I debug the values of the variables by printing them into the message box? I'm having trouble making recognize the correctanswer. If I could print the variables into a message box, that would make the debugging process easier. I want the message box say: 'you entered 'playeranswer' and the correct answer is 'correctanswer'? edit-- I see the previous topic, and that might answer my question, although it looks like a cryptic way to mix variables and text. Edited May 18, 2008 by mayela mingi Quote Link to comment
Ranger Fox Posted May 19, 2008 Share Posted May 19, 2008 The line would look like this: Wherigo.MessageBox{Text=[[You entered ]] .. var .. [[ and the correct answer is ]] .. correctvar .. [[.]],} Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.