Automatic action to take after a period of time...

Folks,

I am working on my first IF game, and it is a big one. Anyways, I am trying to have an action take place after 5 rounds in being in a room. This is what I thought it would look like:

If the player is on the Third Floor: After 5 turns: say "Avatar: Ok, I have unlocked it for you! Let's get out of here!"; unlock the access hatch; end if;

I am a bit unsure as to what to change to get this to work right.

Also, I may be at a disadvantage here. I have been a computer programmer for almost 20 years, so this natural language coding is completely foreign to me.

Timing can be done in several ways. The most straightforward ones are the countdown-type ‘At the time when’ phrase and the ‘every turn’ rules.

[code]After going to the Third Floor:
the avatar intercedes in five turns from now;

At the time when the avatar intercedes:
if the location is Third Floor and the access hatch is locked begin;
say “Avatar: Ok, I have unlocked it for you! Let’s get out of here!”;
now the access hatch is unlocked;
end if;
[/code]
(‘The avatar intercedes’ is an arbitrary phrasing.) Or you might want a number to count down:

hatch-count is a number that varies. hatch-count is 0.

Every turn when the location is Third Floor and the access hatch is locked:
now hatch-count is hatch-count + 1;
if hatch-count > 4 begin;
(do whatever)
end if;

The important thing to remember is that you can’t just write a rule and expect it to trigger on its own: generally, if it’s not tied to a particular player action, you want to tie it to an ‘every turn’ rule.

There are two ways of doing the unlocking thing. If you just want the thing to become unlocked, use now:

now the access hatch is unlocked;

But if you want it to process the action as if the player had performed it - going through all the consequences of the player trying a particular action, which might include failure, etc. - you want this:

try unlocking the access hatch;

Note that the standard action is actually “unlocking it with,” that is unlocking something with something, so in the second case you would have “try unlocking the access hatch with the key” or whatever it is that unlocks the hatch. (But it seems more likely that you want “Now the access hatch is unlocked” anyway.)

Oh, yeah. (This is indicative of how often I make anything to do with locks and keys. To say nothing of lighting, transparency, and the like.)

Maga, your suggestion worked exactly how I thought it would! Thank you very much for all of your help!!