Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

User Input for Math Game

edited October 2016 in Help! with 2.0
Greetings all,

I'm a math teacher that is wanting to create a game for my students. I'm very new to Twine, and frankly don't have much more than a basic understanding of coding. While it would be very easy to make my game using multiple choice answers, I was wondering if there was a way to allow user inputs that take them to different pages. For example if they type in "32" it takes them to a "Correct" screen and if they type in anything else it takes them to an "Incorrect" screen.

Any help would be appreciated. Thanks in advance!

Comments

  • welcome to twine, first things first you should state your twine version, story format and sometimes your story format version, now I don't know what format your using but hopefully if you're using the default format (harlowe 1.22) here's a standard example (the name of the value doesn't matter you could use $x or $banana it wouldn't matter)
    (set: $value1 to (prompt: "Q1. 8 x 4"))
    [[Check answer]]
    (if: $value1 is 32)[(go-to:"Correct")] (else:)[(go-to: "Incorrect")]
    
    This a very simple example to make it work you would need to create 4 passages the passage where the question is, the "Check answer" passage where the {if code} should be there and of course the "Correct" and "Incorrect" passages, this is of course just a build and you must customise it to add more questions and I haven't tested but it should work and good luck in making your game :smile:
  • Other than having to put quotations around 32 that worked perfectly. Thank you so much!
  • you're welcome :smile:
Sign In or Register to comment.