melting ice

Using Cleared Events by Daniel Stelzer, I have the following:

After inserting the holder of the ice cube into the freezer:
   now the freezer is closed;
   say "You close the freezer, and the water instantly freezes back into ice.";
   now the printed name of the ice cube is "some ice";
   the ice cube melts never.

This does pretty much exactly what I want it to do, but I was hoping I could refine the printed name a little bit. Instead of using just “some ice”, I’d like to use “some ice in the shape of [the holder].” Obviously this doesn’t work, as that is what I tried already and I wouldn’t be writing this post if it had. So what is the actual solution?

Thanks!

I don’t know if Inform knows what you mean by “the holder”. Maybe try

[code]To say icedesc:
if ice cube is in a container (called C):
say "some ice in the shape of [the C];
otherwise:
say “a strangely-shaped block of ice”

The printed name of ice cube is “[icedesc]”.
Understand “strangely/shaped/strangely-shaped/block” as ice cube.[/code]

You probably want to record the shape as a variable object.

Also, don’t include “some” as part of the printed name (or else Inform will refer to “the some ice”). Change the indefinite article instead.

The ice cube has an object called the shape. The shape of the ice cube is the ice cube.
The printed name of the ice cube is "[if the shape of the ice cube is the ice cube]ice cube[otherwise]ice in the shape of [a shape of the ice cube]".

After inserting the holder of the ice cube into the freezer:
	now the freezer is closed;
	say "You close the freezer, and the water instantly freezes back into ice.";
	now the shape of the ice cube is the holder of the ice cube;
	now the indefinite article of the ice cube is "some".

(If you want the ice to return to cube form, you’ll need to set the shape of the ice cube to be the ice cube, and change its indefinite article back to “an”.)

I don’t know whether the interaction with Cleared Events will cause any complications.

If all you wanted to do was to change the description of the ice cube, and to have it retain that description even after it left the holder, you could do this:

After inserting the holder of the ice cube into the freezer: now the freezer is closed; say "You close the freezer, and the water instantly freezes back into ice."; now the printed name of the ice cube is the substituted form of "ice in the shape of [a holder of the ice cube]"; now the indefinite article of the ice cube is "some"; now the ice melts never.

The “substituted form” thing is an important trick. If we just said “ice in the shape of [a holder of the ice cube]”, that would make the printed name a function that kept track of whatever the holder of the ice cube was, so the description would change when the holder changed. But when you add “substituted form” that freezes (as it were) the printed name at the present moment–so if the holder of the ice cube is the piggy bank, it evaluates “a holder of the ice cube” to “a piggy bank,” and then makes the printed name “ice in the shape of a piggy bank” and it stays that way until it changes.

Thanks matt w! That is exactly what I was looking for! I had no idea about substituted forms. That could be very handy later on down the road.

Also Hanon O’s method wasn’t what I needed for this part, but it *did help me figure out how to basically do nested if statements in say commands (don’t know if I’m explaining myself properly).

Thanks guys!

Glad to help, and glad my often wrongheaded examples serve some purpose!

I have found it very handy to use say tokens (say “[thiscomplicatedthingthatinvolveslotsofrules]”) that can work out all the detail elsewhere when it would be messy or impossible inline.