how to make a countdown

I’ve got an ice cube. I want it to melt, but not right away. The player needs to put it on the windowsill, then the ice melts in five turns. Here’s a small snippet of what I have, though I don’t know if there’s a simpler way to go about it:


A cubecount is a number that changes.  Cubecount is 5.

Place is a room.

An ice cube is in Place.

A windowsill is a supporter in Place.

Every turn when the cube is on the windowsill:
	now cubecount is cubecount - 1.

I know that if I do this, the cubecount will eventually go into negative numbers, which is not something I want. I want the cubecount to stay at 0 once it gets there. And of course, I’d need some sort of notification once the cubecount hits 0 to let the player know that the cube has melted.

I also have a similar issue where after the player performs a specific action, they only have a limited number of turns to complete another action in order to keep from dying.

Any ideas? Thanks!

I think that this should work:

Cubecount is a number that varies.  Cubecount is 5.

Place is a room.

A windowsill is a supporter in Place.

An ice cube is on the windowsill.

Every turn when the ice cube is on the windowsill and cubecount > 0:
		now cubecount is cubecount - 1.

This sounds like a good use case for timed events! Optionally with Cleared Events since I usually end up needing it when I use timed events.

[code]The windowsill is a supporter.

After putting the ice cube on the windowsill:
say “It heats up and begins to melt; it will be nothing but water soon.”;
the ice cube melts in five turns from now.

At the time when the ice cube melts:
say “The ice cube melts away into water.”;
remove the ice cube from play.

[ To be able to cancel the melting, you can change the remaining time with “the ice cube melts never”… ]

Include Cleared Events by Daniel Stelzer.

The freezer is a container.

After inserting the ice cube into the freezer:
say “It solidifies again into a hard piece of ice.”;
the ice cube melts never.[/code]

perfect, Draconis! thank you so much!!

i found your extension on github (github.com/i7/extensions/blob/m … Events.i7x), but I am confused as to how to download the file so that I can install it on Inform…

Click on the “Raw” button and save the page that it opens.

Thanks, Juhana. I tried following your directions, but it saved it as a .txt file instead of an .i7x extension. Am I doing something wrong?

I7 extensions are text files. Just change the file extension to .i7x.

Another thing that usually works for me is right-clicking on the “Raw” button and choosing “Save File As…” (or whatever it is on that browser and OS). That seems to automatically save it as an .i7x.

finally got it. you all ROCK.