Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How Do I? (http://www.alice.org/community/forumdisplay.php?f=28)
-   -   How to save user word input (string) to make score? (http://www.alice.org/community/showthread.php?t=12263)

WinterIsComing 10-15-2020 04:40 PM

How to save user word input (string) to make score?
 
[SOLVED]

This is not for a school project. I use Alice as a hobby and the current "home" project I'm doing is for a family online experience (due to COVID remote distancing). That said, I set up a theme where a character asks my nephew to put his user input after being asked a question (in which the character will respond with being incorrect or correct). However, the user input is a string and not an integer. This is where I'm having some confusion.

How do I have the program "store" or save my nephew's word, not interger, answer to calculate for a score at the end of the animation?

So far, I made a list of appropriate global scene variable textstrings that are the words of the name of the objects in my animation. Basically he is being asked ot name the objects in the animation.

I have a proper:

If *getstringfromuser* "Question" *equalsignorecase* this."__" Then this character says "Good job!" else "Incorrect!" statement"

I have all my questions and If Then statements setup and my character responding with the appropriate response, but I don't know how to keep track of the correct answers to create a score or total in the end.

djslater107 10-16-2020 08:22 AM

Scoreboard for Games
 
Here is a link to a .pdf of a set of Powerpoint slides that describe how to create a scoreboard from an Alice text object (I am assuming you are working in Alice 2 - let me know if you need this information for Alice 3, although the principles are very close, or if you have problems with the link).

[URL="https://www.dropbox.com/s/tjhim81gku1lklg/Gaming%20-%20Scoreboard%20.pdf?dl=0"]https://www.dropbox.com/s/tjhim81gku1lklg/Gaming%20-%20Scoreboard%20.pdf?dl=0[/URL]

In the slides, the score is increased when the cow is clicked on with the mouse. In your case, you would increase the score when a correct answer is given in the if statement.

Let me know if you have any other questions.

Don Slater
Alice Project

[email]don@alice.org[/email]

WinterIsComing 10-16-2020 08:47 AM

[QUOTE=djslater107;58822]Here is a link to a .pdf of a set of Powerpoint slides that describe how to create a scoreboard from an Alice text object (I am assuming you are working in Alice 2 - let me know if you need this information for Alice 3, although the principles are very close, or if you have problems with the link).

[URL="https://www.dropbox.com/s/tjhim81gku1lklg/Gaming%20-%20Scoreboard%20.pdf?dl=0"]https://www.dropbox.com/s/tjhim81gku1lklg/Gaming%20-%20Scoreboard%20.pdf?dl=0[/URL]

In the slides, the score is increased when the cow is clicked on with the mouse. In your case, you would increase the score when a correct answer is given in the if statement.

Let me know if you have any other questions.

Don Slater
Alice Project

[email]don@alice.org[/email][/QUOTE]



I am working with Alice 3.6. I love the scorekeeper idea but unfortunately, my sister (his mother) wants me to show him the game using a more challenging approach to the coding. The goal is once I have his scores added up for a "grand total", I have the animation tell him his percentage (to simulate granting a grade) based on the total correct out of the number of questions. An exception to this would be I assume, that the score keeper method can be used to do the same thing? Add up all the scores to give a total percentage from how many problems right? Thank you for your response.

WinterIsComing 10-16-2020 10:51 AM

Solved
 
Nevermind, I solved the issue!

I added these codes

[IMG]https://i.imgur.com/b5uLtoz.png[/IMG]
[IMG]https://i.imgur.com/aA49orS.png[/IMG]
[IMG]https://i.imgur.com/sc8FF4a.png[/IMG]

djslater107 10-16-2020 12:31 PM

use of variables
 
I am going to assume that you are riding this myFirstMethod...

Create two variables in myFirstMethod, by dragging the variable tile at the bottom of the screen to the beginning of myFirstMethod.

1) set the [B]valueType[/B] of each to [B]DecimalNumber[/B]
2) name one [B]attempts[/B], and the other [B]correct[/B]
3) set the initializer value of each 0.0

Every time that a question is displayed, increase the attempts variable by 1
1) drag the [B]assign[/B] tile into the appropriate place in your code
2) select [B]attempts -> attempts[/B] from the menu that appears
3) click on the [B]attempts[/B] tile on the right-hand side of the [B]<-[/B] operator
4) from the drop-down menu select [B]Math[/B]
5) from the submenu that appears select [B]attempts + ???[/B]
6) from the next submenu select [B]1.0[/B]

Repeat this process for the correct variable in the appropriate part of your code

After you have finished asking all the questions.

Create another variable, results, and store the correct / results value

Then display this results variable as part of a say statement

Let me know if you have any more questions.

All the best,
Don Slater


All times are GMT -5. The time now is 11:07 PM.

Copyright ©2021, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.