Creation edit box link Harlowe

Hello, I am a newcomer and I create games for the blind in the Czech Republic.
I am facing this problem.
I want to create an edit box where the player would write the answer to the question.
If he answers correctly, he moves to the next room.
If he answers wrong, he stays where he is now.
Thanks for your answer
Jiří Škrába

1 Like

Which Twine version and story format are you using? (Harlowe, Sugarcube, Chapbook?)

The code format is different depending on that.

Hello,

sorry I did not specify the version and format of the story.

So far, I’m not very good at the site.

Version Twine 2.3.14

Harlow format.

Am I blind and my screen reader can’t see everything and Google Translate?

Thank you and have a nice day

Jiří Škrába

image001.jpg

1 Like

Allowing the player to enter a value is easy, checking if the player entered the correct value is a little more complex than you may expect.

You can use the (input-box:) macro to allow the player to enter a value…

What is the capital city of the Czech Republic?
(input-box: bind _answer, "X", 1)

Checking if they entered the correct value of Prague requires a little work because the player may choose to enter:

  1. no value.
  2. a value of a different data-type than you’re expecting. eg. 12345
  3. a value with a different letter casing than you’re expecting. eg. “pRAguE”
  4. a value that has leading and/or trailing white-space characters. eg. " Prague "

In this specific use-case you can use the (trimmed:) macro to overcome the 4th issue, and the (lowercase:) macro to overcome the 3rd issue. For the 1st and 2nd issues we will just structure the checking code in a way that ignores them.

(link-repeat: "Check Answer")[{
	(set: _answer to (trimmed: (lowercase: _answer)))
	(if: _answer is "prague")[
		(goto: "Welcome to Prague")
	]
}]

note: I have used a Temporary Variable in the above examples because you didn’t state that you to wanted access to the answer in later Passages. If you do want such access then change all the instances of the _answer Temporary Variable to be a Story Variable instead.

Hi, thanks for Makra, but unfortunately. No matter what I do, this message pops up:

bindVarRef is not defined►

I put in the game

(input-box: bind _answer, “X”, 1)

and changed to variables

(input-box: bind $ answer, “X”, 1) and the message is the same.

I did the same with the second code.

Can you please guide me in which direction to go?

Thank you so much

Jiří Škrába

image001.jpg

Try removing the space between $ and the variable name:

(input-box: bind $answer, "X",1)

Hello,

I’m a beginner and I might ask stupidly.
Must a variable string be created before this Macro (input-box: bind _answer, “X”, 1) for (input-box:) to work?
Because otherwise I don’t understand why it doesn’t work.
I created the game Test.html, where I wrote the string Macros, which I got from you.
I could send this demo via email, but I have no idea if attachments are allowed or deliverable.
I would be very pleased if there was a Czech or a Slovak.
Now I have written a text that I will translate in Google, and when I read my post, it is translated into Czech, but completely different.

Thanks for your answer
Jiří Škrába

Which version of Harlowe are you using?

According to the (input-box:) macro documentation it was added to Harlow in version 3.2.0 so you need to be using that version or later. The current version of Harlowe is 3.2.3

Whenever Harlowe comes across an undefined variable refence while processing the contents of a Passage, it automatically defines that variable and assigns a default numerical value of zero to it.
So while you don’t need to pre-define your variables, it is generally a good idea to do so, which means my first example really should of looked something like the following…

What is the capital city of the Czech Republic?
(set: _answer to "")\
(input-box: bind _answer, "X", 1)

I don’t understand why it doesn’t work.

What exactly happens or doesn’t happen?
(because stating something “doesn’t work” isn’t that informative, and makes working out why difficult :slight_smile: )

Hi, that was a hit.

As old as I am, I’m stupid!

Yes, in Harlowe 3.2.2, it works.

Thank you and I’m calling hooray.

I still have a lot to learn.

Nice days

Jiří Škrába