Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I just did this in a text editor, so I hope I got all the brackets and indents right. It is untested.

I have assumed that the door is between room01 and room02. You go north from room01 to room02 and south from room02 to room01. The door is initially locked and closed and is unlocked using the key. The door appears in both rooms and can be opened, closed, locked and unlocked from both sides. Room and object definitions are not shown. You can optionally use a barrier if you want the exits to appear and disappear depending on whether or not the door is open.

Enjoy.

booleans {
   is_door_locked : boolean "true";
   is_door_open : boolean "false";
}
on_command {
   : if (is_present "door") {
      : match "examine door" {
         : append "It's a large door that's currently ";
         : if (is_door_open) {
            : print "open.";
            : done;
         }
         : print "closed.";
         : done;
      }
      : match "open door" {
         : if (is_door_open) {
            : print "It's already open.";
            : done;
         }
         : if (is_door_locked) {
            : print "It's locked.";
            : done;
         }
         : set_true "is_door_open";
         : print "You open the door.";
         : done;
      }
      : match "close door" {
         : if (!is_door_open) {
            : print "It's already closed.";
            : done;
         }
         : set_false "is_door_open";
         : print "You close the door.";
         : done;
      }
      : match "unlock door" {
         : if (!is_door_locked) {
            : print "It's already unlocked.";
            : done;
         }
         : if (is_carried "key") {
            : set_false "is_door_locked";
            : print "You unlock the door with the key.";
            : done;
         }
         : print "You'll need a key to unlock the door.";
         : done;
      }
      : match "lock door" {
         : if (is_door_locked) {
            : print "It's already locked.";
            : done;
         }
         : if (is_door_open) {
            : print "You'll have to close it first.";
            : done;
         }
         : if (is_carried "key") {
            : set_true "is_door_locked";
            : print "You lock the door with the key.";
            : done;
         }
         : print "You'll need a key to lock the door.";
         : done;
      }
      : match "n _" {
         : if (is_at "room01" && !is_door_open) {
            : print "You'll have to open the door first.";
            : done;
         }
      }
      : match "s _" {
         : if (is_at "room02" && !is_door_open) {
            : print "You'll have to open the door first.";
            : done;
         }
      }
   }
}
on_pre_describe {
   : if (is_just_entered() && (is_at "room01" || is_at "room02")) {
      : create "door";
   }
}

Fab!  Thanks Garry.

(1 edit)

 on_pre_describe {} doesn't work in 8-bit compatibility mode, but you won't need it if you describe the door in the location text itself or somewhere else.