Working with numbers. (Solved)

Hello,

I’m new to Inform 7, and I’m practicing Inform’s language right now to get hang of it.

My problem at the moment is getting the following code to work:

[code]The number A is a number that varies.

The number B is a number that varies.

number A is usually 2. number B is 5.

The result is a number that varies.

result is usually number A + number B.

When play begins:
say “The result is [result in decimal notation].”.[/code]

This is the error it results in:

I’d also like to know how to get a number as the reader’s input and use it.

Thanks for reading,
OldTimes.

I’m not quite sure what you’re trying to do with ‘usually’ here. What you’re trying to do would be expressed by

number A is 2.
number B is 5.
result is 7.

But my guess is that you want ‘result’ to track A and B. You can’t do that with ‘usually’, which will only set the initial value. For that, you want something more like

[code]number A is 2.
number B is 5.

Every turn: now result is number A + number B.[/code]

How you do this depends on how you want the player’s command to work. Most simply, you’d create a new action that was just about entering numbers:

[code]
Enumerating is an action applying to one number. Understand “[number]” as enumerating.

Instead of enumerating: say “You just entered [the number understood].”[/code]

Rather than an every-turn rule, you could define a function:

To decide what number is the current result: decide on number A + number B.

Thank you both for the help.