Percentage of a countdown

In certain sections of my game I’ve got a countdown going and want to display text when that countdown reaches certain numbers. I’m hoping to future proof this a little by setting up those moments to fire at whole number percentages of the original starting number, so that later I can adjust the original starting number in response to tester feedback without having to edit the math of whole thing.

I’ve read through Chapter 15 and unfortunately it doesn’t offer enough practical usage for the likes of me.

Below is some fake code to give a sense of what I’m hoping to do. Obviously, this is not correct.

Kitchen is a room.

The Microwave is scenery in Kitchen. The description of Kitchen is "You just popped your frozen dinner into the microwave and now wait for it to finish."

StartingTime is a number. StartingTime is 12.
MicrowaveCountdown is a number that varies. MicrowaveCountdown is initially 12.

Every turn when the player is in Kitchen:
	if MicrowaveCountdown is not 0:
		decrease MicrowaveCountdown by 1;
		if MicrowaveCountdown is ((StartingTime)-(StartingTime multiplied by .75 rounded to the nearest whole number))":
			say "'This is taking forever.'";
		if MicrowaveCountdown is ((StartingTime)-(StartingTime multiplied by .5 rounded to the nearest whole number)):
			say "Your stomach rumbles.";
		if MicrowaveCountdown is ((StartingTime)-(StartingTime multiplied by .25 rounded to the nearest whole number)):
			say "'So close and yet so far.'";
	otherwise if MicrowaveCount is 0:
		say "*BEEP*".

This way I could change StartingTime (and MicrowaveCountdown) as much as I want without also having to edit the structure of the “every turn”.

That’s pretty close to working. Just a few tweaks:

Kitchen is a room.

The Microwave is scenery in Kitchen. The description of Kitchen is "You just popped your frozen dinner into the microwave and now wait for it to finish."

Starting Time is a number that varies. Starting Time is 12.
Microwave Countdown is a number that varies. Microwave Countdown is initially 12.
Microwave Running is a truth state that varies. Microwave Running is initially true.

Every turn when the player is in Kitchen:
	if Microwave Countdown is not 0:
		decrease Microwave Countdown by 1;
		if Microwave Countdown is ((Starting Time)-(Starting Time multiplied by 0.75 to the nearest whole number)):
			say "'This is taking forever.'";
		if Microwave Countdown is ((Starting Time)-(Starting Time multiplied by 0.5 to the nearest whole number)):
			say "Your stomach rumbles.";
		if Microwave Countdown is ((Starting Time)-(Starting Time multiplied by 0.25 to the nearest whole number)):
			say "'So close and yet so far.'";
	otherwise if Microwave Countdown is 0 and Microwave Running is true:
		say "*BEEP*";
		now Microwave Running is false;

I fixed some phrase and syntax problems, and added a flag to turn the microwave off so that it doesn’t beep forever. Is this what you’re looking for?

Edit: The Inform 7 idiom is to use multiword identifiers rather than camel case, so I changed those.

Ok, so really it was just the zeros I was missing on the front of those percentages and dropping the “rounded”. Got it.

Yes, this was just a burner bit of code I wrote for the sake of an example and I didn’t include basic niceties like keeping it from beeping forever.

Thank you!