I’m working on a game that has a few secret passageways scattered throughout. One thing that I’m struggling with is the design for hidden exits and doors. I’m trying to achieve an effect where an exit is hidden from the player. The exit should not be listed when the user types
exits, and it should not be included when using code such as this:
(current player $Player ($Player is $ $Loc) (collect $Dir) *(from $Loc go $Dir to room $) (into $Exits)
Here’s some boilerplate code I’ve been playing around with to try and get this to work. It seems like I should be able to use the special
(door is revealed) rule to show/hide an exit like this,
(if) (door is revealed) (then) (from * go #west to #bedroom) (endif)
but I can’t get it to work. I have a feeling I’m missing something pretty basic here.
(intro) (now) (#player is #in #chamber) (look #chamber) #player (current player *) #chamber (room *) (singleton *) (name *) a stone chamber (look *) A stone chamber without any exits. A lever is on the wall though. %% This exit should be hidden by default. %% I'd like to do something like this. %% (if) (door is revealed) (then) %% (from * go #west to #bedroom) %% (endif) (from * go #west to #bedroom) #lever (item *) (switchable *) (name *) metal lever (dict *) switch (* is #in #chamber) %% Custom actions. (after [switch on *]) You hear the grinding of stone. (now) (door is revealed) (prevent [switch off *]) Not when you've revealed the exit! You can't stay here forever. (instead of [pull *]) (try [switch on *]) #bedroom (room *) (singleton *) (name *) The king's bedroom (look *) The bedroom is dominated by a large, carved four-poster bed. (from * go #east to #chamber) %% Custom grammar for "flip lever" (understand [flip | $Word] as [switch $Obj]) *(understand $Word as single object $Obj)
Thanks for any help!