Page 1 of 1

Help with a code for user-input answers?

Posted: Wed Jul 29, 2015 9:04 pm
by Juno
I've searched far and wide for a simple way to do this, but to no avail. I feel like this shouldn't be difficult to do on Ren'Py, although I have little experience coding.

I have two weeks until I take a placement test at my school and instead of using flashcards, I wanted something where it could give me a word or words, then I could fill in the user input blank with the answer. I can either get it right, or wrong. If I get it wrong, it could just give me the correct word and move on. If I get it right, it moves on. Nothing complicated.

Not all answers need to be on the same screen. It could be flashcard-like. I just would prefer to type out my answers as opposed to selecting them from a list of options. Something like this:
dumbgif.gif
Is this possible, and easy to do? Thanks for any help.

Re: Help with a code for user-input answers?

Posted: Thu Jul 30, 2015 12:08 am
by PyTom

Code: Select all


label start:
    $ questions = [
        ("What is the answer to the great question of life, the universe, and everything?", "42"),
        ("How much wood could a woodchuck chuck if a woodchuck could chuck wood?", "42kg/day"),
        ("What is 43 minus 1?", "42"),
       ]


    $ renpy.random.shuffle(questions)

    while questions:
        $ q, a = questions.pop()

        $ answer = renpy.input(q)
        if answer == a:
            "That's right!"
        else:
            "Wrong. The right answer is [a]."

    "Done."

Re: Help with a code for user-input answers?

Posted: Thu Jul 30, 2015 6:09 pm
by Juno
Thank you so much! <3

That's exactly what I need.