inform7

Locking a door in Inform7 works in one case but not another


Hoping there is someone active on this tag I will issue a problem regarding Inform7 here. We currently use this language in college to get in contact with the structure of splicing projects and tasks in a group.

The current task is to unlock a door when a button is pressed and close it after one turn. The code I use is the following:

doorOpen is a number which varies. doorOpen is 0. [ = false]

TuerK is a door. It is south of Flur006R and north of R028a. It is locked.
Tbutton_flur is in Flur006R. Tbutton_flur can be pushed.
Instead of pushing Tbutton_flur:
    now TuerK is unlocked;
    say "Die Tür öffnet sich";
    now doorOpen is 2;

Every turn when doorOpen is 1:
    now doorOpen is 0;
    now TuerK is locked;
    say "Door closes!".

Every turn when doorOpen is 2:
    decrement doorOpen.

Tbutton_raum is in R028a. Tbutton_raum can be pushed.
Instead of pushing Tbutton_raum:
    now TuerK is unlocked;
    say "Door opens!";
    now doorOpen is 2;

Where I use doorOpen as an attribute to check whether the door was open or not. Problem now is that I can push the button, go to the opened room, it says that the door is beeing closed, but I can go out of the room without any problems and it appears that it is unlocked from now on.

On the other hand I have other code:

TuerSiT is a door. It is south of R024 and north of Flur005R. It is locked.

The Sicherheitsausweis unlocks TuerSiT.

Before going to R024:
    if player is holding Sicherheitsausweis:
        now TuerSiT is unlocked;
        say "Der Sicherheitsausweis hat die Tür entsperrt";
    otherwise:
        now TuerSiT is locked.

Where the now doorname is locked works totally fine.

Is there anything I did incorrectly? I also tried to create hidden keys to have the unlocked because that was where I thought the problem was, but it seems I am unable to lock the door.

Any help is much appreciated!


Solution

  • So it appears the one first has to close the door, which was something I did not test on the other door. So

    now the door is closed;
    now the door is locked.
    

    works all fine.