Temporary Portable Light — 1 of 0

John Timmons

Release 1

"Temporary Portable Light" by John Timmons

The story headline is "A Temporary Portable Light to Illuminate a Dark Room." The story description is "This is an example of one way to create a portable light source (flashlight device) that will provide light for a limited amount of time based on the number of turns."

Release along with the source text and a website.

[This is our starting room.]

The Foyer is a room. "The foyer is barren except for a flaming torch attached to the wall. There is an exit to the north."

The Kitchen is north of the Foyer. It is dark. "It seems like a normal kitchen now that there is some light in here."

[We create a device called a flashlight and locate it in the Foyer. The next sentence tells Inform that associated with the flashlight is a variable called charge that will hold a numerical value. The last sentence gives charge a specific numerical value.]

A flashlight is a device in the Foyer. The flashlight has a number called charge. The charge of the flashlight is 10.

[This before statement first checks to see if the value of the charge is less than 0. If it is, the flashlight should be lit because it is out of power. Second we check if the flashlight is already on and stop the action if it is. Last, if the charge is still greater than 0, the flashlight will be lit (providing light.)]

Before switching on the flashlight:

if charge of flashlight is less than 0 begin;

say "It's no use. This flashlight is dead as a doornail.";

stop the action;

otherwise if flashlight is switched on;

say "The flashlight is already switched on.";

stop the action;

otherwise;

now the flashlight is lit;

continue the action;

end if.

[Here we provide for switiching off the flashlight so it will no longer be providing light.]

Carry out switching off the flashlight:

now the flashlight is dark.

[The following checks for various things during every turn of the game. It checks first to see if the charge is greater than 0 because, if it isn't there is no need to continue. Second it checks to see if the flashlight is turned on and, if it is, the charge of the flashlight is decreased by 1. Note that this will only happen if the flashlight is turned on otherwise this will all be ignored. Several messages will appear when the value of the charge reaches certain points to give the player a heads-up on the status of the flashlight. Once the charge of the flashlight reaches 0, the flashlight will become dark (no longer providing light.)]

Every turn:

if charge of flashlight is greater than 0 begin;

if flashlight is switched on begin;

decrease the charge of flashlight by 1;

if charge of flashlight is 5 begin;

say "The flashlight seems to be getting dimmer.";

otherwise if charge of flashlight is 2;

say "The flashlight is getting very dim.";

otherwise if charge of flashlight is 0;

say "The flashlight dies out.";

now the flashlight is dark;

end if;

end if;

end if.