Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[I7] Checking how long something has been unlit

0 views
Skip to first unread message

Clay Hobbs

unread,
Nov 23, 2009, 7:52:00 PM11/23/09
to
I am working on an interactive fiction in which there is an object
which is normally lit. The only way to turn it off is to attack it,
which I made work with:

Instead of attacking the lamp:
now the lamp is unlit.

Now I'm trying to check how long it has been unlit. My goal is to
make it so if it has been unlit for two turns, move the player to
another room. Unfortunately, I'm having some trouble making this
rule. Thank you in advance.

Al

unread,
Nov 23, 2009, 8:36:51 PM11/23/09
to

Starter is a room.

a thing is either lit or unlit.
a thing is usually unlit.

The player carries a lamp.

the lamp has a number called litturns.
the litturns of the lamp is 0.

instead of attacking an unlit lamp:
now the lamp is lit;
say "You hit the lamp and light it.";

instead of attacking a lit lamp:
now the lamp is unlit;
say "You hit the lamp and it goes out.";
now the litturns of the lamp is 0.

every turn when the lamp is lit:
increase the litturns of the lamp by 1.

instead of examining the lamp:
if the lamp is lit begin;
Say "The lamp has been lit for [litturns of the lamp] turns.";
otherwise;
say "The lamp is not lit.";
end if.

Al

unread,
Nov 23, 2009, 8:41:28 PM11/23/09
to
OOPS my bad

the code should read:

Starter is a room.

a thing is either lit or unlit.
a thing is usually unlit.

The player carries a lamp.

the lamp has a number called unlitturns.
the unlitturns of the lamp is 1.

instead of attacking an unlit lamp:
now the lamp is lit;
say "You hit the lamp and light it.";

decrease the unlitturns of the lamp by 1;

instead of attacking a lit lamp:
now the lamp is unlit;
say "You hit the lamp and it goes out.";

increase the unlitturns by 1.

every turn when the lamp is unlit:
increase the unlitturns of the lamp by 1.

instead of examining the lamp:

if the lamp is unlit begin;
Say "The lamp has been unlit for [unlitturns of the lamp] turns.";
otherwise;
say "The lamp is lit;
end if.

Roger

unread,
Nov 23, 2009, 8:50:26 PM11/23/09
to

One way to accomplish this is to create an event. Here is how:

[code]
"Unlit" by Roger Helgeson Jr.

The Dining Room is a room. The Basement is a room.

The lamp is a device. The lamp is in the Dining Room. The lamp is lit.
The lamp is switched on. The description of the lamp is "A lamp. It is
currently [if the lamp is unlit]un[end if]lit."

Instead of switching on the lamp:
now the lamp is lit.

Instead of switching off the lamp:


now the lamp is unlit.

Instead of attacking the lamp:

say "You hit the lamp and it goes off.";


now the lamp is unlit;

the unlit-lamp-event returns in two turns from now.

At the time when the unlit-lamp-event returns:
if the lamp is unlit and the lamp has been unlit for two turns:
move the player to the Basement;
say "Because the lamp has been off, you've been carried away to your
own basement by a grue. What a grue-ling experience!"

Test me1 with "x lamp / attack lamp / x lamp / z".
Test me2 with "x lamp / attack lamp / x lamp / turn on lamp / z / z /
z".
Test me3 with "x lamp / turn off lamp / x lamp / z / z / z / z / z".
Test me4 with "attack lamp / z / turn on lamp / z / z / z / attack
lamp / z / turn on lamp / z / z / z / attack lamp / z / z".
[/code]

(Restart after each test.)

Test me1 illustrates that the player will be moved to the Basement if
the lamp is consistently unlit for 2 turns, it will move the player to
the Basement.

Test me2 illustrates that the player can prevent being dragged off to
the Basement if he turns the lamp back on after attacking it.

Test me3 illustrates that this only occurs if the player turns the
lamp off via the "attack" command and not simply by switching the lamp
off.

Test me4 illustrates that the "2 turn" counter resets when the player
turns the lamp back on. Here you are attacking the lamp, waiting a
turn, and turning it back on multiple times. Overall, the lamp is
unlit for three turns, but it doesn't matter - the event is created
after the player "attacks" the lamp, so it only recognizes 2 turns
from when the event is created within the "Instead of attacking the
lamp" block of code. At least, that's how I think it works.

Clay Hobbs

unread,
Nov 23, 2009, 9:03:53 PM11/23/09
to

Yes, that seems to work exactly how I wanted! Except that the lamp in
your example could be switched on, it's almost the same as my code.
Thank you very much.

Roger

unread,
Nov 23, 2009, 9:27:05 PM11/23/09
to

You're welcome. Al's example is worth looking at too. There are
multiple ways to arrive at the same result.

Clay Hobbs

unread,
Nov 24, 2009, 11:15:21 AM11/24/09
to
Okay, now I have it so the player is moved to a different room. The
only problem is that when the player is moved there, the description
of the room is printed twice. I've tried moving around various lines
from my source text, but I can't figure out how to make it print only
once. I think it may have something to do with the fact the the
player is in a dark room with light provided by the lamp. Does anyone
have any ideas as to how to fix this?

Jim Aikin

unread,
Nov 24, 2009, 4:34:27 PM11/24/09
to

There is a known I7 bug that can be triggered when you manually move a
player to or from a dark room. I forget the details, but it was in a
thread on the newsgroup a month or so ago. The only workaround I'm aware
of is, wait for the next release.

But maybe someone can suggest a kludge.

--JA

Roger

unread,
Nov 24, 2009, 7:16:24 PM11/24/09
to

I reproduced the bug. If the Dining Room (in my example) is dark, with
the lamp initially providing light, and then the player turns off the
lamp and is "moved" to a lit location, the room description prints
twice. However, this is easy to kludge-fix. Simply add the "without
printing a room description" clause to your "move" phrase, as
illustrated below:

[code]
"Unlit" by Roger Helgeson Jr.

The Dining Room is a room. The description is "A dining room. You dine
here. In the room."
The Basement is a room. The description is "A basement. You base here.
In the ment."

The lamp is a device. The lamp is in the Dining Room. The lamp is lit.
The lamp is switched on. The description of the lamp is "A lamp. It is
currently [if the lamp is unlit]un[end if]lit."

Instead of switching on the lamp:
now the lamp is lit.

Instead of switching off the lamp:
now the lamp is unlit.

Instead of attacking the lamp:
say "You hit the lamp and it goes off.";
now the lamp is unlit;
the unlit-lamp-event returns in two turns from now.

The Dining Room is dark.

At the time when the unlit-lamp-event returns:
if the lamp is unlit and the lamp has been unlit for two turns:

move the player to the Basement, without printing a room
description;


say "Because the lamp has been off, you've been carried away to your
own basement by a grue. What a grue-ling experience!"

Test me with "attack lamp / z / z".
[/code]

It gets rid of ONE of the room description printings. If you want to
get rid of both, I'm afraid I can't help you, but that will address
this specific issue, Clay.

Clay Hobbs

unread,
Nov 24, 2009, 8:56:03 PM11/24/09
to

Thank you very much. I decided that for my game, it is actually more
natural-seeming to make the other room dark when you arrive there and
have it become bright after two turns. I might use this somewhere
else in the game though. Thanks again.

0 new messages