# Evaluating a property based on number

I have several things whose property changes based on a number that changes often. I initially evaluated the property with definitions but that has no effect at all. I tried a To Decide statement instead but that won’t even compile. I left my attempt in the below commented out.

``````Lab is a room.

Ground is a kind of thing. Ground is scenery. Ground has a number called Grime. Grime is initially 1.

Ground can be clean, dusty, soiled, or filthy (this is its tidyness property).

Definition: A ground is clean if its Grime is 0.
Definition: A ground is dusty if its Grime is 1.
Definition: A ground is soiled if its Grime is 2.
Definition: A ground is filthy if its Grime is greater than 2.

[To decide the tidyness of a ground:
if Grime of the noun is greater than 2, decide on filthy;
if Grime of the noun is 2, decide on soiled;
if Grime of the noun is 1, decide on dusty;
decide on clean.]

A ground called Tile Floor is in Lab.

After waiting in Lab:
say "You eat some cookies to pass the time and drop a bunch of crumbs.";
increment Grime of Tile Floor.

The description of Tile Floor is "A [tidyness of Tile Floor] off-white tile floor."

Test me with "x floor / z / x floor / z / x floor".
``````

I’m clearly approaching this the wrong way. Can somebody point me to how I should be doing this?

2 Likes

Here’s one solution:

``````Lab is a room.

Ground is a kind of thing. Ground is scenery. Ground has a number called Grime. Grime is initially 1.

To decide what text is the tidyness of (G - a ground):
if Grime of G > 2, decide on "filthy";
if Grime of G is 2, decide on "soiled";
if Grime of G is 1, decide on "dusty";
decide on "clean".

A ground called Tile Floor is in Lab.

After waiting in Lab:
say "You eat some cookies to pass the time and drop a bunch of crumbs.";
increment Grime of Tile Floor.

The description of Tile Floor is "A [tidyness of Tile Floor] off-white tile floor."

Test me with "x floor / z / x floor / z / x floor".
``````

The problem you’re having is that you’re trying to make “tidyness” do double-duty. You define it as a property (think of this as a variable), but then you try to also make it a value calculated from the grime (i.e., a function). You have to choose one or the other.

Instead of texts, which I use, you could make something like:

``````cleanliness is a kind of value. The cleanlinesses are clean, dusty, soiled, and filthy.
``````
4 Likes

If you want to stick with “grime” as a numerical property, I’d probably just do a to-say statement:

``````To say tidyness of (X - a ground):
If grime of X is 0, say "clean";
Otherwise if grime of X is 1:
say "dusty";
Otherwise if grime of X is 2:
say "soiled";
Otherwise:
Say "filthy".

...

The description of Tile Floor is "A [tidyness of Tile Floor] off-white tile floor."
``````
3 Likes

Use enumerated values. Much simpler than converting to a number, incrementing the number then converting back.

``````"The Lab"

Tidiness is a kind of value. The tidinesses are clean, dusty, soiled, filthy.

The Lab is A Room. The tile floor is in the lab. The tile floor is scenery. The tile floor has a tidiness. The tidiness of the tile floor is clean. The description of tile floor is "A [tidiness of the tile floor] off-white tile floor.".

After waiting in the lab:
say "You eat some cookies to pass the time and drop a bunch of crumbs.";
if the tidiness of the tile floor is not filthy, now the tidiness of the tile floor is the tidiness after the tidiness of the tile floor.

Test me with "x floor / z / x floor / z / x floor / z / x floor".
``````

Hope this helps!

8 Likes

Ah, this is the phrase I wanted.

2 Likes

I likewise dimly remembered there was a way to do this, but couldn’t immediately find it in the docs and went with a blunter approach

1 Like

That’ll be “§11.18. The value after and the value before”!

It’s also used in “Disenchantment Bay”, which is how I remembered it (found the actual documentation afterwards).

3 Likes

I marked enumerated values as the solution because it’s the best answer to the question I posed. But my WIP was built using numbers for various things and I decided later “I bet I could tie some descriptions to these” after the fact so Phil’s “to decide” but be the thing that makes most sense for my particular project.

1 Like

Fair do’s! It is however a useful technique to keep in your back pocket for future use!

It’s worth knowing that

``````To decide what K is a/an/-- (v - value) cast as a/an/-- (name of kind of value K): (- {v} -).
``````

lets you go back and forth from numbers and enumerated values (though one must remember that enumerated values begin it 1).

2 Likes