# Question re Player Setting Values

I’m new to I7 so this may be a rookie error, but I am trying to allow a player to change the value to a number determined by the player.

In this case, the player will get in a car and determine how fast the car is going. Too slow and he can’t get up the hill; too fast and he crashes around the curves. But I am having a problem figuring out how to allow the player to adjust the “speed” value of the car.

Here is what I have so far, but the error seems to be in the carry out function. Depending on the coding, it either tells me I can’t change a value, or is unrecognized. I tried it with a number but then it gives me a runtime error. I have a feeling the fix is really simple and I just overlooked it. Any suggestions? Thanks.

``````Speed is a kind of value.  65mph specifies a speed.  65 mph specifies a speed.   A speedometer has a speed.  A speed is usually 10 mph.

A Speedometer is scenery. Understand "sm" as speedometer. A speedometer is in the car.  Instead of examining speedometer:
say "You are going [speed of the car].".

The verb to accelerate (he accelerates, he accelerated, it is accelerated, he is accelerating) implies the speed property.

Changed speed is a speed that varies.

Accelerating is an action applying to one value.  Understand "accelerate to [a speed]" and "set speed to [a speed]" as accelerating.

Check accelerating:
if the player is not in the car, say "It's best to be in the car first." instead.

Carry out accelerating:
now the value of the changed speed is the speed;
let the changed speed be the speed of the car;
say "Now the speed of the car is [speed of the car].".

Garage is a room.  "A basic garage."  Street is a room.  "A flat street."  Street is south of the garage.

The car is a a vehicle. The car is in the garage.  The car is pushable between rooms.  The description of the car is "Your car's a little old, but it'll get you where you're going.  [line break][line break]The speedometer is straight in front of you. (You can call a speedometer an 'sm' for input purposes.)" A car has a speed.``````

You are just having a little trouble with the syntax.
Try this:

```Carry out accelerating: now the changed speed is the speed understood; now the speed of the car is the changed speed; say "Now the speed of the car is [speed of the car]."```

Whenever you use your own kinds as grammar tokens in action commands (like »accelerate to [speed]») you need to refer to them as »understood» in the rules that govern the action—so »now the changed speed is the speed understood». And to set a variable X to a certain value N, just say »now X is N» (not »now the value of X is N»).

This, »let the changed speed be the speed of the car», has two issues: first, it sets the variable ”changed speed” to the value of the variable ”speed of the car” rather than vice versa (its always the first variable mentioned that gets changed); second, in Inform, »let X be N» can only be used of temporary, local variables (variables that only exist while executing a single rule), but ”changed speed” is a global variable (i.e. you can access it from any rule in the game), so you need to use a good old »now X is N».

By the way, if you don’t use the ”changed speed” variable for any other purpose, you don’t need it all. You can put the speed understood directly into the speed of the car:```Carry out accelerating: now the speed of the car is the speed understood; say "Now the speed of the car is [speed of the car]."```

Thanks! I’ll give this a go and see how it all works out.

Just a quick note. This bit is unneeded if you just want the accelerating action.

The vocabulary for the action is defined with the understand bits.

Also, it’s best not to use instead rules for examining.

It’s much better to use the description.

``The description of the speedometer is say "You are going [speed of the car].".``

Finally, you have a speed for both the speedometer and the car.

``A speedometer has a speed.``

This could potentially cause errors as the speed of the speedometer and the speed of the car can easily get out of sync. It’s best to use one variable for both.

Hope this helps.