# How do I create a value calculated from other values?

Here is my issue…
I am using position as a number value for persons. I want to calculate distance between two persons as the absolute difference in their positions, thusly

``` Let X be the position of the noun; Let Y be the position of the actor; Let distance be the absolute value of (X minus Y); if the range of the second noun is less than the distance: say "[the noun] is about [distance] paces away. Your [second noun] is out of range." instead.```

This works when I put it into an action. But I want to find a way to use an equation, decide phrase, or the equivalent to calculate distance between an actor and a noun every time I need it.

My trials suggest that neither an equation nor a decide phrase can handle passed variables, i.e. the position of the actor. Is that right? Is there another way to do this?

An equation probably has more overhead cost than you need here. I’d use a decide phrase.

``To decide what number is the distance between (the attacker - a thing) and (the target - a thing): decide on the absolute value of (the position of the attacker minus the position of the target).``

Yeah, I’ve rarely seen people use equations. They seem mostly to be syntactic sugar: pretty in an NL way, but not all that useful.

They’re useful sometimes when you have a very complicated formula with several functions involved. But usually, yeah.

```To decide if (opponent - a person) is strikable: Let X be the position of opponent; Let Y be the position of the player; Let distance be the absolute value of (X minus Y); if the range of the player is less than the distance: decide yes; decide no.```
```If the noun is strikable [and the noun is not defending and the noun is not invulnerable etc]: [do stuff]```